<!DOCTYPE html><html><head>
      <title>wiki_gsoap</title>
      <meta charset="utf-8">
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      
      <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.13.18/dist/katex.min.css">
      
      
      
      
      
      
      
      
      
      <style>
      /**
 * prism.js Github theme based on GitHub's theme.
 * @author Sam Clarke
 */
code[class*="language-"],
pre[class*="language-"] {
  color: #333;
  background: none;
  font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace;
  text-align: left;
  white-space: pre;
  word-spacing: normal;
  word-break: normal;
  word-wrap: normal;
  line-height: 1.4;

  -moz-tab-size: 8;
  -o-tab-size: 8;
  tab-size: 8;

  -webkit-hyphens: none;
  -moz-hyphens: none;
  -ms-hyphens: none;
  hyphens: none;
}

/* Code blocks */
pre[class*="language-"] {
  padding: .8em;
  overflow: auto;
  /* border: 1px solid #ddd; */
  border-radius: 3px;
  /* background: #fff; */
  background: #f5f5f5;
}

/* Inline code */
:not(pre) > code[class*="language-"] {
  padding: .1em;
  border-radius: .3em;
  white-space: normal;
  background: #f5f5f5;
}

.token.comment,
.token.blockquote {
  color: #969896;
}

.token.cdata {
  color: #183691;
}

.token.doctype,
.token.punctuation,
.token.variable,
.token.macro.property {
  color: #333;
}

.token.operator,
.token.important,
.token.keyword,
.token.rule,
.token.builtin {
  color: #a71d5d;
}

.token.string,
.token.url,
.token.regex,
.token.attr-value {
  color: #183691;
}

.token.property,
.token.number,
.token.boolean,
.token.entity,
.token.atrule,
.token.constant,
.token.symbol,
.token.command,
.token.code {
  color: #0086b3;
}

.token.tag,
.token.selector,
.token.prolog {
  color: #63a35c;
}

.token.function,
.token.namespace,
.token.pseudo-element,
.token.class,
.token.class-name,
.token.pseudo-class,
.token.id,
.token.url-reference .token.variable,
.token.attr-name {
  color: #795da3;
}

.token.entity {
  cursor: help;
}

.token.title,
.token.title .token.punctuation {
  font-weight: bold;
  color: #1d3e81;
}

.token.list {
  color: #ed6a43;
}

.token.inserted {
  background-color: #eaffea;
  color: #55a532;
}

.token.deleted {
  background-color: #ffecec;
  color: #bd2c00;
}

.token.bold {
  font-weight: bold;
}

.token.italic {
  font-style: italic;
}


/* JSON */
.language-json .token.property {
  color: #183691;
}

.language-markup .token.tag .token.punctuation {
  color: #333;
}

/* CSS */
code.language-css,
.language-css .token.function {
  color: #0086b3;
}

/* YAML */
.language-yaml .token.atrule {
  color: #63a35c;
}

code.language-yaml {
  color: #183691;
}

/* Ruby */
.language-ruby .token.function {
  color: #333;
}

/* Markdown */
.language-markdown .token.url {
  color: #795da3;
}

/* Makefile */
.language-makefile .token.symbol {
  color: #795da3;
}

.language-makefile .token.variable {
  color: #183691;
}

.language-makefile .token.builtin {
  color: #0086b3;
}

/* Bash */
.language-bash .token.keyword {
  color: #0086b3;
}

/* highlight */
pre[data-line] {
  position: relative;
  padding: 1em 0 1em 3em;
}
pre[data-line] .line-highlight-wrapper {
  position: absolute;
  top: 0;
  left: 0;
  background-color: transparent;
  display: block;
  width: 100%;
}

pre[data-line] .line-highlight {
  position: absolute;
  left: 0;
  right: 0;
  padding: inherit 0;
  margin-top: 1em;
  background: hsla(24, 20%, 50%,.08);
  background: linear-gradient(to right, hsla(24, 20%, 50%,.1) 70%, hsla(24, 20%, 50%,0));
  pointer-events: none;
  line-height: inherit;
  white-space: pre;
}

pre[data-line] .line-highlight:before, 
pre[data-line] .line-highlight[data-end]:after {
  content: attr(data-start);
  position: absolute;
  top: .4em;
  left: .6em;
  min-width: 1em;
  padding: 0 .5em;
  background-color: hsla(24, 20%, 50%,.4);
  color: hsl(24, 20%, 95%);
  font: bold 65%/1.5 sans-serif;
  text-align: center;
  vertical-align: .3em;
  border-radius: 999px;
  text-shadow: none;
  box-shadow: 0 1px white;
}

pre[data-line] .line-highlight[data-end]:after {
  content: attr(data-end);
  top: auto;
  bottom: .4em;
}html body{font-family:"Helvetica Neue",Helvetica,"Segoe UI",Arial,freesans,sans-serif;font-size:16px;line-height:1.6;color:#333;background-color:#fff;overflow:initial;box-sizing:border-box;word-wrap:break-word}html body>:first-child{margin-top:0}html body h1,html body h2,html body h3,html body h4,html body h5,html body h6{line-height:1.2;margin-top:1em;margin-bottom:16px;color:#000}html body h1{font-size:2.25em;font-weight:300;padding-bottom:.3em}html body h2{font-size:1.75em;font-weight:400;padding-bottom:.3em}html body h3{font-size:1.5em;font-weight:500}html body h4{font-size:1.25em;font-weight:600}html body h5{font-size:1.1em;font-weight:600}html body h6{font-size:1em;font-weight:600}html body h1,html body h2,html body h3,html body h4,html body h5{font-weight:600}html body h5{font-size:1em}html body h6{color:#5c5c5c}html body strong{color:#000}html body del{color:#5c5c5c}html body a:not([href]){color:inherit;text-decoration:none}html body a{color:#08c;text-decoration:none}html body a:hover{color:#00a3f5;text-decoration:none}html body img{max-width:100%}html body>p{margin-top:0;margin-bottom:16px;word-wrap:break-word}html body>ul,html body>ol{margin-bottom:16px}html body ul,html body ol{padding-left:2em}html body ul.no-list,html body ol.no-list{padding:0;list-style-type:none}html body ul ul,html body ul ol,html body ol ol,html body ol ul{margin-top:0;margin-bottom:0}html body li{margin-bottom:0}html body li.task-list-item{list-style:none}html body li>p{margin-top:0;margin-bottom:0}html body .task-list-item-checkbox{margin:0 .2em .25em -1.8em;vertical-align:middle}html body .task-list-item-checkbox:hover{cursor:pointer}html body blockquote{margin:16px 0;font-size:inherit;padding:0 15px;color:#5c5c5c;background-color:#f0f0f0;border-left:4px solid #d6d6d6}html body blockquote>:first-child{margin-top:0}html body blockquote>:last-child{margin-bottom:0}html body hr{height:4px;margin:32px 0;background-color:#d6d6d6;border:0 none}html body table{margin:10px 0 15px 0;border-collapse:collapse;border-spacing:0;display:block;width:100%;overflow:auto;word-break:normal;word-break:keep-all}html body table th{font-weight:bold;color:#000}html body table td,html body table th{border:1px solid #d6d6d6;padding:6px 13px}html body dl{padding:0}html body dl dt{padding:0;margin-top:16px;font-size:1em;font-style:italic;font-weight:bold}html body dl dd{padding:0 16px;margin-bottom:16px}html body code{font-family:Menlo,Monaco,Consolas,'Courier New',monospace;font-size:.85em !important;color:#000;background-color:#f0f0f0;border-radius:3px;padding:.2em 0}html body code::before,html body code::after{letter-spacing:-0.2em;content:"\00a0"}html body pre>code{padding:0;margin:0;font-size:.85em !important;word-break:normal;white-space:pre;background:transparent;border:0}html body .highlight{margin-bottom:16px}html body .highlight pre,html body pre{padding:1em;overflow:auto;font-size:.85em !important;line-height:1.45;border:#d6d6d6;border-radius:3px}html body .highlight pre{margin-bottom:0;word-break:normal}html body pre code,html body pre tt{display:inline;max-width:initial;padding:0;margin:0;overflow:initial;line-height:inherit;word-wrap:normal;background-color:transparent;border:0}html body pre code:before,html body pre tt:before,html body pre code:after,html body pre tt:after{content:normal}html body p,html body blockquote,html body ul,html body ol,html body dl,html body pre{margin-top:0;margin-bottom:16px}html body kbd{color:#000;border:1px solid #d6d6d6;border-bottom:2px solid #c7c7c7;padding:2px 4px;background-color:#f0f0f0;border-radius:3px}@media print{html body{background-color:#fff}html body h1,html body h2,html body h3,html body h4,html body h5,html body h6{color:#000;page-break-after:avoid}html body blockquote{color:#5c5c5c}html body pre{page-break-inside:avoid}html body table{display:table}html body img{display:block;max-width:100%;max-height:100%}html body pre,html body code{word-wrap:break-word;white-space:pre}}.markdown-preview{width:100%;height:100%;box-sizing:border-box}.markdown-preview .pagebreak,.markdown-preview .newpage{page-break-before:always}.markdown-preview pre.line-numbers{position:relative;padding-left:3.8em;counter-reset:linenumber}.markdown-preview pre.line-numbers>code{position:relative}.markdown-preview pre.line-numbers .line-numbers-rows{position:absolute;pointer-events:none;top:1em;font-size:100%;left:0;width:3em;letter-spacing:-1px;border-right:1px solid #999;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.markdown-preview pre.line-numbers .line-numbers-rows>span{pointer-events:none;display:block;counter-increment:linenumber}.markdown-preview pre.line-numbers .line-numbers-rows>span:before{content:counter(linenumber);color:#999;display:block;padding-right:.8em;text-align:right}.markdown-preview .mathjax-exps .MathJax_Display{text-align:center !important}.markdown-preview:not([for="preview"]) .code-chunk .btn-group{display:none}.markdown-preview:not([for="preview"]) .code-chunk .status{display:none}.markdown-preview:not([for="preview"]) .code-chunk .output-div{margin-bottom:16px}.scrollbar-style::-webkit-scrollbar{width:8px}.scrollbar-style::-webkit-scrollbar-track{border-radius:10px;background-color:transparent}.scrollbar-style::-webkit-scrollbar-thumb{border-radius:5px;background-color:rgba(150,150,150,0.66);border:4px solid rgba(150,150,150,0.66);background-clip:content-box}html body[for="html-export"]:not([data-presentation-mode]){position:relative;width:100%;height:100%;top:0;left:0;margin:0;padding:0;overflow:auto}html body[for="html-export"]:not([data-presentation-mode]) .markdown-preview{position:relative;top:0}@media screen and (min-width:914px){html body[for="html-export"]:not([data-presentation-mode]) .markdown-preview{padding:2em calc(50% - 457px + 2em)}}@media screen and (max-width:914px){html body[for="html-export"]:not([data-presentation-mode]) .markdown-preview{padding:2em}}@media screen and (max-width:450px){html body[for="html-export"]:not([data-presentation-mode]) .markdown-preview{font-size:14px !important;padding:1em}}@media print{html body[for="html-export"]:not([data-presentation-mode]) #sidebar-toc-btn{display:none}}html body[for="html-export"]:not([data-presentation-mode]) #sidebar-toc-btn{position:fixed;bottom:8px;left:8px;font-size:28px;cursor:pointer;color:inherit;z-index:99;width:32px;text-align:center;opacity:.4}html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] #sidebar-toc-btn{opacity:1}html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc{position:fixed;top:0;left:0;width:300px;height:100%;padding:32px 0 48px 0;font-size:14px;box-shadow:0 0 4px rgba(150,150,150,0.33);box-sizing:border-box;overflow:auto;background-color:inherit}html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc::-webkit-scrollbar{width:8px}html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc::-webkit-scrollbar-track{border-radius:10px;background-color:transparent}html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc::-webkit-scrollbar-thumb{border-radius:5px;background-color:rgba(150,150,150,0.66);border:4px solid rgba(150,150,150,0.66);background-clip:content-box}html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc a{text-decoration:none}html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc ul{padding:0 1.6em;margin-top:.8em}html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc li{margin-bottom:.8em}html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc ul{list-style-type:none}html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .markdown-preview{left:300px;width:calc(100% -  300px);padding:2em calc(50% - 457px -  150px);margin:0;box-sizing:border-box}@media screen and (max-width:1274px){html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .markdown-preview{padding:2em}}@media screen and (max-width:450px){html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .markdown-preview{width:100%}}html body[for="html-export"]:not([data-presentation-mode]):not([html-show-sidebar-toc]) .markdown-preview{left:50%;transform:translateX(-50%)}html body[for="html-export"]:not([data-presentation-mode]):not([html-show-sidebar-toc]) .md-sidebar-toc{display:none}
/* Please visit the URL below for more information: */
/*   https://shd101wyy.github.io/markdown-preview-enhanced/#/customize-css */

      </style>
    </head>
    <body for="html-export">
      <div class="mume markdown-preview  ">
      <style>.center {
  text-align: center;
}
.h2 {
  font-size: 1em;
}
img.center {
  display: table;
}
@media screen {
  .printonly {
    display: none !important;
  }
}
</style>
<h1 class="mume-header printonly" id="xa0">&#xA0;</h1>

<h1 class="mume-header printonly" id="xa0-1">&#xA0;</h1>

<style type="text/css">
.red {
    color: #FF0000
}
.mid {
    text-align:center
}
</style>
<h1 class="mume-header center" id="gsoap%E5%85%A5%E9%97%A8%E6%95%99%E7%A8%8B">gSOAP&#x5165;&#x95E8;&#x6559;&#x7A0B;</h1>

<h1 class="mume-header printonly" id="xa0-2">&#xA0;</h1>

<h1 class="mume-header center" id="%E7%9B%AE%E5%BD%95">&#x76EE;&#x5F55;</h1>

<div class="code-chunk" data-id="code-chunk-id-0" data-cmd="toc"><div class="input-div"><div class="btn-group"><div class="run-btn btn"><span>&#x25B6;&#xFE0E;</span></div><div class="run-all-btn btn">all</div></div><div class="status">running...</div></div><div class="output-div"></div></div><ul>
<li><a href="#H-1">1. &#x524D;&#x8A00;</a>
<ul>
<li><a href="#H-1-1">1.1 &#x6982;&#x8FF0;</a></li>
<li><a href="#H-1-2">1.2 &#x57FA;&#x672C;&#x672F;&#x8BED;</a></li>
</ul>
</li>
<li><a href="#H-2">2. gsoap&#x5B89;&#x88C5;&#x4E0E;&#x914D;&#x7F6E;</a>
<ul>
<li><a href="#H-2-1">2.1 &#x8BF4;&#x660E;</a></li>
<li><a href="#H-2-2">2.2 gsoap&#x7F16;&#x8BD1;</a></li>
</ul>
</li>
<li><a href="#H-3">3. gsoap &#x793A;&#x4F8B;&#x4EE3;&#x7801;</a>
<ul>
<li><a href="#H-3-1-1">3.1.1 C.1&#x7248;</a>
<ul>
<li><a href="#H-3-1-1-1">3.1.1.1 calc.wsdl&#x6587;&#x4EF6; --&gt; calc.h</a></li>
<li><a href="#H-3-1-1-2">3.1.1.2 &#x7F16;&#x8F91;&#x670D;&#x52A1;&#x7AEF;&#x6D4B;&#x8BD5;&#x6587;&#x4EF6;: <code>test_calc_server.c</code></a></li>
<li><a href="#H-3-1-1-3">3.1.1.3 &#x7F16;&#x8F91;&#x5BA2;&#x6237;&#x7AEF;&#x6587;&#x4EF6;: <code>test_calc_client.c</code></a></li>
<li><a href="#H-3-1-1-4">3.1.1.4 &#x7F16;&#x8F91;<code>Makefile</code></a></li>
<li><a href="#H-3-1-1-5">3.1.1.5 &#x7F16;&#x8BD1;&#x53CA;&#x8FD0;&#x884C;</a></li>
<li><a href="#H-3-1-1-6">3.1.1.6 &#x6D4B;&#x8BD5;GET&#x63A5;&#x53E3;</a></li>
</ul>
</li>
<li><a href="#H-3-1-2">3.1.2 C.2&#x7248;</a></li>
</ul>
</li>
<li><a href="#H-4">4. FAQ</a>
<ul>
<li><a href="#H-4-1">4.1 FAQ1</a></li>
<li><a href="#H-4-2">4.2 &#x793A;&#x4F8B;&#x6F14;&#x793A;FAQ</a></li>
</ul>
</li>
<li><a href="#H-5">5. &#x9644;&#x5F55;</a>
<ul>
<li><a href="#H-5-1">5.1 gsoap&#x901A;&#x7528;&#x6587;&#x4EF6;</a></li>
<li><a href="#H-5-2">5.2 wsdl&#x547D;&#x4EE4;</a></li>
<li><a href="#H-5-3">5.3 soapcpp2</a></li>
<li><a href="#H-5-4">5.4 &#x5E93;&#x79FB;&#x690D;&#x65B9;&#x6CD5;</a></li>
<li><a href="#H-5-5">5.5 wsdl&#x6587;&#x4EF6;&#x5143;&#x7D20;&#x8BF4;&#x660E;</a>
<ul>
<li><a href="#H-5-5-1">5.5.1 &#x6982;&#x8FF0;</a></li>
<li><a href="#H-5-5-2">5.5.2 &#x5C0F;&#x7ED3;</a></li>
</ul>
</li>
<li><a href="#H-5-6">5.6 SOAP 1.1 vs SOAP 1.2</a></li>
<li><a href="#H-5-7">5.7 GSOAP&#x7528;&#x4F8B;&#xFF1A;C++&#x7248;&#x672C;</a>
<ul>
<li><a href="#H-5-7-1">5.7.1 &#x7F16;&#x8F91;&#x63A5;&#x53E3;&#x6587;&#x4EF6;(<code>zzz.h</code>)</a></li>
<li><a href="#H-5-7-2">5.7.2 &#x7F16;&#x8F91;&#x670D;&#x52A1;&#x7AEF;&#x6587;&#x4EF6;(<code>zzzserver.cpp</code>)</a></li>
<li><a href="#H-5-7-3">5.7.3 &#x7F16;&#x8F91;&#x5BA2;&#x6237;&#x7AEF;&#x6587;&#x4EF6;(<code>zzztest.cpp</code>)</a></li>
<li><a href="#H-5-7-4">5.7.4 &#x7F16;&#x8F91;Makefile</a></li>
<li><a href="#H-5-7-5">5.7.5 &#x7F16;&#x8BD1;&#x53CA;&#x8FD0;&#x884C;</a></li>
<li><a href="#H-5-7-6">5.7.6 &#x4E0E;&#x5176;&#x5B83;&#x5E73;&#x53F0;&#x5BF9;&#x63A5;</a></li>
</ul>
</li>
</ul>
</li>
</ul>
<div class="pagebreak"> </div>
<h2 class="mume-header undefined" id="H-1">1. &#x524D;&#x8A00;</h2>

<p>gSOAP&#x662F;&#x4E00;&#x4E2A;&#x7ED1;&#x5B9A;SOAP/XML&#x5230;C/C++&#x8BED;&#x8A00;&#x7684;&#x5DE5;&#x5177;&#xFF0C;&#x4F7F;&#x7528;&#x5B83;&#x53EF;&#x4EE5;&#x7B80;&#x5355;&#x5FEB;&#x901F;&#x5730;&#x5F00;&#x53D1;&#x51FA;SOAP/XML&#x7684;&#x670D;&#x52A1;&#x5668;&#x7AEF;&#x548C;&#x5BA2;&#x6237;&#x7AEF;&#x3002;&#x7531;&#x4E8E; gSOAP&#x5177; &#x6709;&#x76F8;&#x5F53;&#x4E0D;&#x9519;&#x7684;&#x517C;&#x5BB9;&#x6027;&#xFF0C;&#x901A;&#x8FC7;gSOAP&#xFF0C;&#x6211;&#x4EEC;&#x5C31;&#x53EF;&#x4EE5;&#x8C03;&#x7528;&#x7531;Java, .Net, Delhpi, PHP&#x7B49;&#x8BED;&#x8A00;&#x5F00;&#x53D1;&#x7684;SOAP&#x670D;&#x52A1;&#xFF0C;&#x6216;&#x8005;&#x5411;&#x5B83;&#x4EEC;&#x63D0;&#x4F9B;SOAP&#x670D;&#x52A1;&#x3002;<br>
gSOAP&#x7684;&#x4E3B;&#x9875;&#x662F;:<br>
<a href="http://sourceforge.net/projects/gsoap2">http://sourceforge.net/projects/gsoap2</a></p>
<p>WebService&#x4ECE;&#x6570;&#x636E;&#x4F20;&#x8F93;&#x683C;&#x5F0F;&#x4E0A;&#x4F5C;&#x4E86;&#x9650;&#x5B9A;&#x3002;WebService&#x6240;&#x4F7F;&#x7528;&#x7684;&#x6570;&#x636E;&#x5747;&#x662F;&#x57FA;&#x4E8E;XML&#x683C;&#x5F0F;&#x7684;&#x3002;<br>
WebService&#x901A;&#x8FC7;HTTP&#x534F;&#x8BAE;&#x5B8C;&#x6210;&#x8FDC;&#x7A0B;&#x8C03;&#x7528;: (&#x6DF1;&#x5165;&#x5206;&#x6790;) &#x2013; RPC<br>
WebService&#x53EA;&#x91C7;&#x7528;HTTP POST&#x65B9;&#x5F0F;&#x4F20;&#x8F93;&#x6570;&#x636E;&#xFF0C;&#x4E0D;&#x4F7F;&#x7528;GET&#x65B9;&#x5F0F;; -- &#x63E1;&#x624B;&#xFF0C;WSDL-get,</p>
<h3 class="mume-header undefined" id="H-1-1">1.1 &#x6982;&#x8FF0;</h3>

<ul>
<li>&#x76F8;&#x5173;&#x8D44;&#x6599;
<ul>
<li>&#x8F6F;&#x4EF6;&#x8D44;&#x6599;
<ul>
<li>gsoap<br>
&#x5148;&#x8FDB;&#x5165;&#x5B98;&#x7F51;&#x7684;&#x4E0B;&#x8F7D;&#x9875;&#x9762;&#xFF0C;&#x7136;&#x540E;&#x9009;&#x62E9;&#x5F00;&#x6E90;&#x7248;&#x672C;<br>
<a href="https://www.genivia.com/products.html#gsoap">https://www.genivia.com/products.html#gsoap</a><br>
&#x6216;&#x8005;SVN&#x83B7;&#x53D6;&#x4EE3;&#x7801;&#xFF0C;&#x7136;&#x540E;&#x66F4;&#x65B0;&#x5230;&#x5386;&#x53F2;&#x67D0;&#x4E2A;&#x7248;&#x672C;&#xFF0C;<pre data-role="codeBlock" data-info="shell {.line-numbers}" class="language-shell line-numbers">$ svn checkout https://svn.code.sf.net/p/gsoap2/code/
<span class="token comment"># r188 2020-07-23 / gSOAP 2.8.105 stable</span>
<span class="token comment"># r205 2022-03-08 / gSOAP 2.8.120 stable</span>
$ svn up -r <span class="token number">205</span>
<span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span></span></pre></li>
</ul>
</li>
<li>&#x5B66;&#x4E60;&#x8D44;&#x6599;
<ul>
<li><a href="https://www.cnblogs.com/liushui-sky/p/9723385.html">https://www.cnblogs.com/liushui-sky/p/9723385.html</a> (&#x63A8;&#x8350;)<br>
&#x53EF;&#x4EE5;&#x5B9E;&#x73B0;&#x57FA;&#x672C;&#x7684;&#x5BA2;&#x6237;&#x7AEF;&#x4E0E;&#x670D;&#x52A1;&#x7AEF;&#x7684;&#x4E92;&#x901A;&#x3002;<br>
&#x4F46;&#x4E0D;&#x80FD;&#x5BF9;&#x63A5;WEB SERVICE&#x7684;&#x529F;&#x80FD;&#x51FD;&#x6570;&#xFF0C;&#x6BD4;&#x5982;GET&#x65B9;&#x6CD5;&#x529F;&#x80FD;&#x51FD;&#x6570;&#x3002;<br>
C&#x7248;&#x672C;&#x9700;&#x8981;&#x6DFB;&#x52A0;HTTP&#x65B9;&#x6CD5;&#x5904;&#x7406;&#x51FD;&#x6570;; &#x6DFB;&#x52A0;&#x65B9;&#x6CD5;&#x53EF;&#x53C2;&#x8003;&#xFF1A;<br>
<a href="http://www.cyqdata.com/cnblogs/article-detail-36843">http://www.cyqdata.com/cnblogs/article-detail-36843</a><br>
C++&#x7248;&#x672C;&#x6709;&#x6DFB;&#x52A0;HTTP&#x65B9;&#x6CD5;&#x5904;&#x7406;&#x51FD;&#x6570;&#xFF0C;&#x4F46;&#x662F;&#x7ECF;&#x8C03;&#x8BD5;&#x5931;&#x8D25;&#xFF0C;&#x539F;&#x56E0;&#x4E0D;&#x8BE6;&#x3002;</li>
<li><a href="https://blog.csdn.net/Zhangyuanxuevaq/article/details/79687441">https://blog.csdn.net/Zhangyuanxuevaq/article/details/79687441</a></li>
<li><a href="https://blog.csdn.net/ghostyu/article/details/8162280#">https://blog.csdn.net/ghostyu/article/details/8162280#</a></li>
<li><a href="https://www.cnblogs.com/liuyanygz/p/8622390.html">https://www.cnblogs.com/liuyanygz/p/8622390.html</a></li>
</ul>
</li>
</ul>
</li>
</ul>
<h3 class="mume-header undefined" id="H-1-2">1.2 &#x57FA;&#x672C;&#x672F;&#x8BED;</h3>

<ul>
<li>WSDL &#x7F51;&#x7EDC;&#x670D;&#x52A1;&#x63CF;&#x8FF0;&#x8BED;&#x8A00; (Web Services Description Language)&#x3002;</li>
</ul>
<h2 class="mume-header undefined" id="H-2">2. gsoap&#x5B89;&#x88C5;&#x4E0E;&#x914D;&#x7F6E;</h2>

<h3 class="mume-header undefined" id="H-2-1">2.1 &#x8BF4;&#x660E;</h3>

<ul>
<li>
<p>&#x5F00;&#x53D1;webservice&#x5E94;&#x7528;&#xFF0C;&#x5927;&#x81F4;&#x6709;&#x4E24;&#x4E2A;&#x65B9;&#x5411;&#xFF1A;</p>
<ol>
<li>API&#x63A5;&#x53E3;&#x56FA;&#x5B9A;&#xFF0C;&#x4E0D;&#x5173;&#x5FC3;&#x5E95;&#x5C42;&#x7684;&#x901A;&#x8BAF;&#xFF0C;&#x5C06;SOAP&#x4F5C;&#x4E3A;&#x5E94;&#x7528;&#x5C42;&#x534F;&#x8BAE;<br>
&#x6B64;&#x65F6;&#xFF0C;&#x6211;&#x4EEC;&#x5148;&#x5B9A;&#x4E49;&#x63A5;&#x53E3;&#xFF0C;&#x7F16;&#x5199;&#x597D;.h&#x6587;&#x4EF6;&#xFF0C;&#x8FD0;&#x884C;soapcpp2&#x751F;&#x6210;&#x51FA;&#x76F8;&#x5E94;&#x7684;&#x4EE3;&#x7801;&#xFF0C;&#x5BF9;&#x670D;&#x52A1;&#x5668;&#x7AEF;&#xFF0C;&#x4FEE;&#x6539;XXXService&#x6587;&#x4EF6;&#xFF0C;&#x5B9E;&#x73B0;&#x4E1A;&#x52A1;&#x903B;&#x8F91;&#xFF0C;&#x5BF9;&#x5BA2;&#x6237;&#x7AEF;&#xFF0C;&#x4FEE;&#x6539;XXXProxy&#x6587;&#x4EF6;&#xFF0C;&#x5B9E;&#x73B0;&#x4E1A;&#x52A1;&#x903B;&#x8F91;&#x3002;</li>
<li>&#x901A;&#x8BAF;&#x534F;&#x8BAE;&#x56FA;&#x5B9A;&#xFF08;&#x5F53;&#x7136;&#x9700;&#x8981;&#x57FA;&#x4E8E;XML&#x7684;&#xFF09;&#x6216;&#x53EA;&#x6709;wsdl&#xFF0C;&#x5C06;SOAP&#x4F5C;&#x4E3A;&#x201C;&#x4F20;&#x8F93;&#x5C42;&#x201D;&#x534F;&#x8BAE;<br>
&#x6B64;&#x65F6;&#xFF0C;&#x6211;&#x4EEC;&#x5FC5;&#x987B;&#x6839;&#x636E;&#x901A;&#x8BAF;&#x534F;&#x8BAE;&#x6216;wsdl&#x751F;&#x6210;&#x76F8;&#x5E94;&#x7684;C/C++&#x7C7B;&#x578B;&#x7684;.h&#x6587;&#x4EF6;&#xFF0C;&#x5982;&#x679C;&#x9700;&#x8981;&#x6211;&#x4EEC;&#x81EA;&#x5DF1;&#x7F16;&#x5199;wsdl&#xFF0C;&#x5219;&#x9700;&#x8981;&#x4E00;&#x70B9;&#x5176;&#x76F8;&#x5173;&#x77E5;&#x8BC6;&#xFF0C;&#x4E0D;&#x8FC7;&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x7528;C#&#x7B49;&#x751F;&#x6210;&#x4E00;&#x4E2A;&#x7B80;&#x5355;&#x7684;wsdl&#xFF0C;&#x7167;&#x732B;&#x753B;&#x864E;&#x5373;&#x53EF;&#x3002;&#x8FD0;&#x7528;wsdl2h&#xFF0C;&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x751F;&#x6210;.h&#x6587;&#x4EF6;&#xFF0C;&#x6709;&#x4E86;.h&#x540E;&#xFF0C;&#x6309;&#x4E0A;&#x9762;&#x7684;&#x6B65;&#x9AA4;&#x7EE7;&#x7EED;&#x3002;</li>
</ol>
</li>
<li>
<p>&#x5BA2;&#x6237;&#x7AEF; &#x4E0E; &#x670D;&#x52A1;&#x7AEF; &#x7684;gsoap &#x7248;&#x672C;&#x4E00;&#x5B9A;&#x8981;&#x4E00;&#x81F4;&#xFF0C;&#x4E0D;&#x7136;&#x4F1A;&#x5BFC;&#x81F4;&#x901A;&#x4FE1;&#x95EE;&#x9898;&#xFF1B;&#x4E00;&#x7AEF;&#x80FD;&#x53D1;&#x9001;&#x6210;&#x529F;&#xFF0C;&#x4F46;&#x6536;&#x4E0D;&#x5230;&#x5BF9;&#x7AEF;&#x7684;&#x6570;&#x636E;&#x3002;<br>
&#x7528;gsoap&#x7F16;&#x5199;&#x7F51;&#x7EDC;&#x670D;&#x52A1;&#xFF0C;&#x5F53;&#x5BA2;&#x6237;&#x7AEF;&#x8C03;&#x7528;&#x65F6;&#xFF0C;&#x670D;&#x52A1;&#x7AEF;&#x4F1A;&#x62A5;&#x7248;&#x672C;&#x4E0D;&#x4E00;&#x81F4;&#x7684;&#x9519;&#x8BEF;&#x3002;&#x6B64;&#x65F6;&#xFF0C;&#x5F53;&#x7528;soapcpp2&#x5904;&#x7406;&#x5934;&#x6587;&#x4EF6;&#x662F;&#xFF0C;&#x9700;&#x8981;&#x6307;&#x5B9A;&#x7248;&#x672C;&#x4FE1;&#x606F;&#x3002;<br>
&#x5982;&#xFF1A;</p>
<pre data-role="codeBlock" data-info="shell {.line-numbers}" class="language-shell line-numbers"><span class="token comment"># generate SOAP 1.1 bindings</span>
$ soapcpp2 -1
<span class="token comment"># generate SOAP 1.2 bindings</span>
$ soapcpp2 -2
<span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span></span></pre><ul>
<li>Soap1.1&#x548C;Soap1.2&#x7684;&#x533A;&#x522B;</li>
</ul>
</li>
<li>
<p>wsdl2h&#x7528;&#x4F5C;wsdl&#x548C;.h&#x6587;&#x4EF6;&#x7684;&#x8F6C;&#x6362;&#x3002;<br>
soapcpp2&#x7528;&#x5934;&#x6587;&#x4EF6;&#x751F;&#x6210;&#x5BA2;&#x6237;&#x7AEF;/&#x670D;&#x52A1;&#x7AEF;&#x7B49;&#x5F00;&#x53D1;&#x9700;&#x8981;&#x7684;h&#x548C;cpp&#x6587;&#x4EF6;</p>
<ul>
<li>wsdl2h [-o outfile.h infile.wsdl]<br>
&#x5B9E;&#x73B0;wsdl&#x6587;&#x4EF6;&#x5230;h&#x6587;&#x4EF6;&#x7684;&#x6570;&#x636E;&#x6620;&#x5C04;<br>
&#x901A;&#x8FC7;wsdl2h &#x89E3;&#x6790;webservice&#x7684;wsdl&#x6587;&#x4EF6;&#xFF0C;&#x53EF;&#x4EE5;&#x751F;&#x6210;&#x5BF9;&#x5E94;&#x7684;&#x8C03;&#x7528;&#x4EE3;&#x7801;, &#x5C06;wsdl&#x6587;&#x4EF6;&#x8F6C;&#x6362;&#x4E3A;&#x5934;&#x6587;&#x4EF6;&#x3002;</li>
<li>soapcpp2 [-c outfile.h]<br>
gsoap&#x4EE3;&#x7801;&#x751F;&#x6210;&#x5668;&#x3002;<br>
&#x751F;&#x6210;&#x76F8;&#x5E94;&#x7684;&#x5E95;&#x5C42;&#x901A;&#x4FE1;stub&#xFF0C;strech&#x7A0B;&#x5E8F;</li>
</ul>
</li>
<li>
<p>&#x4F9D;&#x8D56;&#x8D44;&#x6E90;&#x5217;&#x8868;</p>
<pre data-role="codeBlock" data-info="shell {.line-numbers}" class="language-shell line-numbers"><span class="token comment"># &#x5B89;&#x88C5;GTK+&#x7684;&#x5F00;&#x53D1;&#x6587;&#x4EF6;&#x548C;GLib&#x5E93;(libraries)</span>
$ yum <span class="token function">install</span> <span class="token function">make</span> automake gcc gcc-c++ kernel-devel
$ yum -y <span class="token function">install</span> flex bison bison-devel
$ yum <span class="token function">install</span> openssl openssl-devel libssl-dev byacc
<span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span></span></pre><ul>
<li>autoconf-2.69.tar.gz //2012-04-24 23:17	1.8M<br>
wget <a href="https://ftp.gnu.org/gnu/autoconf/autoconf-2.69.tar.gz">https://ftp.gnu.org/gnu/autoconf/autoconf-2.69.tar.gz</a></li>
<li>automake-1.16.2.tar.gz //2020-03-21 18:41	2.2M<br>
wget <a href="https://ftp.gnu.org/gnu/automake/automake-1.16.2.tar.gz">https://ftp.gnu.org/gnu/automake/automake-1.16.2.tar.gz</a></li>
<li>gsoap-2.8.105.zip //7/22/2020<br>
<a href="https://download.csdn.net/download/u013011143/12710159?utm_source=iteye_new">https://download.csdn.net/download/u013011143/12710159?utm_source=iteye_new</a></li>
</ul>
</li>
</ul>
<h3 class="mume-header undefined" id="H-2-2">2.2 gsoap&#x7F16;&#x8BD1;</h3>

<ul>
<li>&#x7F16;&#x8BD1;&#x4F9D;&#x8D56;&#x5E93;
<ul>
<li>autoconf<br>
&#x9ED8;&#x8BA4;&#x5B89;&#x88C5;&#x6A21;&#x5F0F;&#xFF0C;&#x5B89;&#x88C5;&#x8FC7;&#x7A0B;&#x7565;&#x3002;</li>
<li>automake<br>
&#x9ED8;&#x8BA4;&#x5B89;&#x88C5;&#x6A21;&#x5F0F;&#xFF0C;&#x5B89;&#x88C5;&#x8FC7;&#x7A0B;&#x7565;&#x3002;</li>
<li>&#x4F9D;&#x8D56;&#x5E93;&#x5B89;&#x88C5;&#x547D;&#x4EE4;<pre data-role="codeBlock" data-info="shell {.line-numbers}" class="language-shell line-numbers">$ yum <span class="token function">install</span> automake bison flex openssl zlib -y
<span aria-hidden="true" class="line-numbers-rows"><span></span></span></pre></li>
</ul>
</li>
<li>&#x7F16;&#x8BD1;gsoap<br>
gsoap&#x76EE;&#x5F55;&#x4E0B;&#x6709;<code>INSTALL.txt</code>&#xFF0C;&#x91CC;&#x9762;&#x6709;&#x5404;&#x5E73;&#x53F0;&#x4E0B;&#x6E90;&#x7801;&#x5305;&#x7684;&#x7F16;&#x8BD1;&#x6B65;&#x9AA4;&#xFF0C;&#x4EE5;Linux&#x5E73;&#x53F0;&#x4E3A;&#x4F8B;&#xFF0C;&#x73B0;&#x6458;&#x5F55;&#x5982;&#x4E0B;:<pre data-role="codeBlock" data-info="shell {.line-numbers}" class="language-shell line-numbers">$ gsoap-2.8.120.zip
$ <span class="token builtin class-name">cd</span> gsoap-2.8
$ ./configure --prefix<span class="token operator">=</span><span class="token variable"><span class="token variable">`</span><span class="token builtin class-name">pwd</span><span class="token variable">`</span></span>/wrapper
<span class="token comment"># //aclocal</span>
$ automake -a -c
$ <span class="token function">make</span> 
$ <span class="token function">make</span> <span class="token function">install</span>
<span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></pre><ul>
<li>&#x5B89;&#x88C5;&#x540E;&#x7684;&#x76EE;&#x5F55;&#x6811;&#x5982;&#x4E0B;&#x6240;&#x793A;&#xFF08;&#x8FD8;&#x4E0D;&#x5168;&#xFF0C;&#x9700;&#x8981;&#x6DFB;&#x52A0;env&#x7B49;&#x4F9D;&#x8D56;&#x6587;&#x4EF6;&#xFF09;<pre data-role="codeBlock" data-info="shell {.line-numbers}" class="language-shell line-numbers"><span class="token builtin class-name">.</span>
&#x251C;&#x2500;&#x2500; bin
&#x2502;   &#x251C;&#x2500;&#x2500; soapcpp2
&#x2502;   &#x2514;&#x2500;&#x2500; wsdl2h
&#x251C;&#x2500;&#x2500; include
&#x2502;   &#x2514;&#x2500;&#x2500; stdsoap2.h
&#x251C;&#x2500;&#x2500; lib
&#x2502;   &#x251C;&#x2500;&#x2500; libgsoap.a
&#x2502;   &#x251C;&#x2500;&#x2500; libgsoap++.a
&#x2502;   &#x251C;&#x2500;&#x2500; libgsoapck.a
&#x2502;   &#x251C;&#x2500;&#x2500; libgsoapck++.a
&#x2502;   &#x251C;&#x2500;&#x2500; libgsoapssl.a
&#x2502;   &#x251C;&#x2500;&#x2500; libgsoapssl++.a
&#x2502;   &#x2514;&#x2500;&#x2500; pkgconfig
&#x2502;       &#x251C;&#x2500;&#x2500; gsoapck.pc
&#x2502;       &#x251C;&#x2500;&#x2500; gsoapck++.pc
&#x2502;       &#x251C;&#x2500;&#x2500; gsoap.pc
&#x2502;       &#x251C;&#x2500;&#x2500; gsoap++.pc
&#x2502;       &#x251C;&#x2500;&#x2500; gsoapssl.pc
&#x2502;       &#x2514;&#x2500;&#x2500; gsoapssl++.pc        
&#x2514;&#x2500;&#x2500; share
        <span class="token punctuation">..</span><span class="token punctuation">..</span><span class="token punctuation">..</span> <span class="token punctuation">..</span><span class="token punctuation">..</span><span class="token punctuation">..</span>
        <span class="token punctuation">..</span><span class="token punctuation">..</span><span class="token punctuation">..</span> <span class="token punctuation">..</span><span class="token punctuation">..</span><span class="token punctuation">..</span>
<span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></pre></li>
</ul>
</li>
<li>envC.o<br>
&#x5236;&#x4F5C;<code>envC.o</code>&#xFF0C;C&#x7A0B;&#x5E8F;&#x6A21;&#x5F0F;&#x4E0B;&#x7684;&#x94FE;&#x63A5;&#x4F1A;&#x7528;&#x5230;&#x5B83;&#x3002;<pre data-role="codeBlock" data-info="shell {.line-numbers}" class="language-shell line-numbers">$ <span class="token builtin class-name">cd</span> gsoap/samples/link
<span class="token comment"># $ ls </span>
<span class="token comment"># calc.h  env.h  fault.h  gmt.h  header.h  </span>
<span class="token comment"># Makefile  README.txt  xmas.c  xmas.h  xmas.wsdl</span>
$ <span class="token punctuation">..</span>/<span class="token punctuation">..</span>/<span class="token punctuation">..</span>/wrapper/bin/soapcpp2 -p <span class="token function">env</span> -c env.h
<span class="token comment"># $ ls </span>
<span class="token comment"># calc.h  env.h fault.h  gmt.h  header.h  Makefile  README.txt  xmas.c  xmas.h  xmas.wsdl</span>
<span class="token comment"># envC.c  envH.h  envStub.h  h.nsmap  h.xsd  </span>
$ g++ -c -I <span class="token punctuation">..</span>/<span class="token punctuation">..</span>/<span class="token punctuation">..</span>/wrapper/include/ envC.c
<span class="token comment"># $ ls </span>
<span class="token comment"># calc.h  env.h fault.h  gmt.h  header.h  Makefile  README.txt  xmas.c  xmas.h  xmas.wsdl</span>
<span class="token comment"># envC.c  envH.h  envStub.h  h.nsmap  h.xsd  </span>
<span class="token comment"># envC.o</span>
<span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></pre></li>
<li>&#x79FB;&#x690D;<br>
&#x4E3A;&#x4E86;&#x540E;&#x9762;&#x7684;C&#x548C;C++&#x7248;&#x672C;&#x7684;&#x670D;&#x52A1;&#x548C;&#x5BA2;&#x6237;&#x7AEF;&#x7684;&#x5F00;&#x53D1;&#x80FD;&#x591F;&#x8131;&#x79BB;&#x6E90;&#x4EE3;&#x7801;&#x76EE;&#x5F55;&#xFF0C;&#x6700;&#x597D;&#x8FD8;&#x8981;&#x5982;&#x4E0B;&#x5904;&#x7406;&#x3002;<br>
&#x8FD9;&#x91CC;&#x5047;&#x8BBE;gsoap&#x5DF2;&#x7ECF;&#x7F16;&#x8BD1;&#x5B89;&#x88C5;&#xFF0C;&#x4E14;&#x5B89;&#x88C5;&#x540E;&#x7684;&#x76EE;&#x5F55;&#x4E3A;<code>/usr/local/gSOAP2.8.120</code>&#x3002;<pre data-role="codeBlock" data-info="shell {.line-numbers}" class="language-shell line-numbers">$ <span class="token builtin class-name">cd</span> <span class="token punctuation">..</span>/<span class="token punctuation">..</span>/<span class="token punctuation">..</span>/wrapper
$ <span class="token function">ls</span> 
bin  include  lib  share
<span class="token comment"># &#x5207;&#x6362;&#x5230;&#x89E3;&#x538B;&#x7F29;&#x540E;&#x7684;GSOAP&#x76EE;&#x5F55;&#xFF0C;&#x7136;&#x540E;&#x8FDB;&#x884C;&#x4EE5;&#x4E0B;COPY&#x52A8;&#x4F5C;</span>
$ <span class="token function">mkdir</span> <span class="token function">env</span>  src <span class="token function">import</span>

<span class="token comment"># &#x79FB;&#x690D;env&#x76EE;&#x5F55;&#xFF0C;&#x5982;&#x679C;&#x4E4B;&#x524D;&#x672A;&#x7F16;&#x8BD1;&#x8FC7;env&#xFF0C;&#x4E5F;&#x53EF;&#x4EE5;&#x79FB;&#x690D;&#x540E;&#x518D;&#x7F16;&#x8BD1;envC.o</span>
$ <span class="token function">cp</span> <span class="token punctuation">..</span>/gsoap/samples/link/* env/
<span class="token comment"># &#x79FB;&#x690D;stdsoap*&#x6587;&#x4EF6;</span>
$ <span class="token function">cp</span> <span class="token punctuation">..</span>/gsoap/stdsoap*.* src/
<span class="token comment"># &#x79FB;&#x690D;import&#x76EE;&#x5F55;</span>
$ <span class="token function">cp</span> -r <span class="token punctuation">..</span>/gsoap/import/* import/
<span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></pre></li>
</ul>
<h2 class="mume-header undefined" id="H-3">3. gsoap &#x793A;&#x4F8B;&#x4EE3;&#x7801;</h2>

<ul>
<li>wsdl&#x6587;&#x4EF6;&#x8303;&#x4F8B;<pre data-role="codeBlock" data-info="shell {.line-numbers}" class="language-shell line-numbers">$ wsdl2h -o calc.h http://www.genivia.com/calc.wsdl
<span class="token comment"># </span>
//gsoapopt c++,w

//gsoap ns2   schema namespace: urn:calc
//gsoap ns2   schema form:  unqualified

//gsoap ns2  <span class="token function">service</span> name:  calc
//gsoap ns2  <span class="token function">service</span> type:  calcPortType
//gsoap ns2  <span class="token function">service</span> port:  http://websrv.cs.fsu.edu/~engelen/calcserver.cgi
//gsoap ns2  <span class="token function">service</span> namespace: urn:calc
//gsoap ns2  <span class="token function">service</span> transport: http://schemas.xmlsoap.org/soap/http

//gsoap ns2  <span class="token function">service</span> method-protocol:   <span class="token function">add</span> SOAP
//gsoap ns2  <span class="token function">service</span> method-style:  <span class="token function">add</span> rpc
//gsoap ns2  <span class="token function">service</span> method-encoding:   <span class="token function">add</span> http://schemas.xmlsoap.org/soap/encoding/
//gsoap ns2  <span class="token function">service</span> method-action: <span class="token function">add</span> <span class="token string">&quot;&quot;</span>
//gsoap ns2  <span class="token function">service</span> method-output-action:  <span class="token function">add</span> Response

//gsoap ns2  <span class="token function">service</span> method-protocol:   sub SOAP
//gsoap ns2  <span class="token function">service</span> method-style:  sub rpc
//gsoap ns2  <span class="token function">service</span> method-encoding:   sub http://schemas.xmlsoap.org/soap/encoding/
//gsoap ns2  <span class="token function">service</span> method-action: sub <span class="token string">&quot;&quot;</span>
//gsoap ns2  <span class="token function">service</span> method-output-action:  sub Response
<span class="token punctuation">..</span>. <span class="token punctuation">..</span>.
<span class="token punctuation">..</span>. <span class="token punctuation">..</span>.
<span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></pre></li>
</ul>
<h4 class="mume-header undefined" id="H-3-1-1">3.1.1 C.1&#x7248;</h4>

<ul>
<li>&#x524D;&#x63D0;&#xFF1A;<br>
gsoap&#x5E93;&#x7F16;&#x8BD1;&#x5E76;&#x79FB;&#x690D;&#x5B8C;&#x6BD5;&#x3002;</li>
<li>&#x8BF4;&#x660E;&#xFF1A;<br>
a. &#x7528;soapcpp2&#x751F;&#x4EA7;gsoap&#x76F8;&#x5173;&#x4EE3;&#x7801;&#xFF1A; soapcpp2 -c -x ${WSNAME}.h<br>
b. &#x670D;&#x52A1;&#x7AEF;&#x6240;&#x9700;&#x7684;&#x4EE3;&#x7801;&#xFF1A; soapC.c soapServer.c stdsoap2.c<br>
c. &#x5BA2;&#x6237;&#x7AEF;&#x6240;&#x9700;&#x7684;&#x4EE3;&#x7801;&#xFF1A; soapC.c soapClient.c stdsoap2.c<br>
d. &#x5176;&#x4E2D;stdsoap2.c&#x662F;&#x4ECE;gsoap&#x5F00;&#x53D1;&#x5305;&#x4E2D;&#x590D;&#x5236;&#x8FC7;&#x6765;&#x7684;&#xFF0C;&#x4ED6;&#x7684;&#x6587;&#x4EF6;&#x662F;(a)&#x4E2D;&#x547D;&#x4EE4;&#x4EA7;&#x751F;&#x7684;&#x3002;</li>
</ul>
<h5 class="mume-header undefined" id="H-3-1-1-1">3.1.1.1 calc.wsdl&#x6587;&#x4EF6; --&gt; calc.h</h5>

<p>&#x6709;&#x4E24;&#x79CD;&#x65B9;&#x5F0F;: &#x4E00;&#x79CD;&#x662F;&#x4FEE;&#x6539;&#x73B0;&#x6709;&#x7684;&#x6216;&#x7F51;&#x7EDC;&#x4E0B;&#x8F7D;&#x7684;<code>.wsdl</code>&#x6587;&#x4EF6;&#xFF0C;&#x53E6;&#x4E00;&#x79CD;&#x5C31;&#x662F;&#x65B0;&#x5EFA;gsoap&#x683C;&#x5F0F;&#x7684;<code>.h</code>&#x6587;&#x4EF6;&#xFF0C;&#x540E;&#x7EED;&#x6267;&#x884C;<code>soapcpp2</code>&#x547D;&#x4EE4;&#x540E;&#xFF0C;&#x4F1A;&#x81EA;&#x52A8;&#x751F;&#x6210;&#x76F8;&#x5E94;&#x7684;<code>.wsdl</code>&#x6587;&#x4EF6;&#xFF0C;&#x63A8;&#x8350;&#x4F7F;&#x7528;&#x540E;&#x9762;&#x7684;&#x65B9;&#x5F0F;&#x3002;</p>
<ul>
<li>&#x64CD;&#x4F5C;&#x6B65;&#x9AA4;<pre data-role="codeBlock" data-info="shell {.line-numbers}" class="language-shell line-numbers"><span class="token comment"># &#x65B9;&#x5F0F;1: &#x5F15;&#x7528;&#x7F51;&#x7EDC;wsdl&#xFF0C;&#x4F46;&#x4E0D;&#x80FD;&#x76F4;&#x63A5;&#x7528;&#xFF0C;&#x9700;&#x8981;&#x5254;&#x9664;&#x591A;&#x4F59;&#x63A5;&#x53E3;&#xFF0C;</span>
<span class="token comment"># &#x5207;&#x8BB0;: .wsdl&#x4E2D;&#x7684;&#x51FD;&#x6570;&#x63A5;&#x53E3;&#xFF0C;&#x9700;&#x8981;&#x4FDD;&#x6301;&#x4E0E;&#x65B9;&#x5F0F;2&#x7684;&#x63A5;&#x53E3;&#x76F8;&#x540C;&#xFF0C;&#x56E0;&#x4E3A;:</span>
<span class="token comment"># &#x672C;&#x793A;&#x4F8B;&#x662F;&#x4EE5;&#x65B9;&#x5F0F;2&#x6765;&#x6F14;&#x793A;&#x7684;&#x3002;&#x4E0D;&#x7136;&#x4F1A;&#x5728;&#x94FE;&#x63A5;&#x8FC7;&#x7A0B;&#x4E2D;&#x56E0;&#x4E3A;&#x627E;&#x4E0D;&#x5230;&#x63A5;&#x53E3;&#x5B9A;&#x4E49;&#x800C;&#x5F15;&#x8D77;&#x94FE;&#x63A5;&#x9519;&#x8BEF;&#x3002;</span>
<span class="token comment">#$ wget http://www.genivia.com/calc.wsdl</span>
<span class="token comment"># &#x65B9;&#x5F0F;2</span>
$ <span class="token function">vim</span> calc.h
//gsoap ns <span class="token function">service</span> name: calc
//gsoap ns <span class="token function">service</span> style: rpc
//gsoap ns <span class="token function">service</span> namespace: http://10.10.90.46:9000/calc.wsdl
//gsoap ns <span class="token function">service</span> location: http://10.10.90.46:9000
//gsoap ns <span class="token function">service</span> encoding: encoded
//gsoap ns schema namespace: urn:calc

int ns__add<span class="token punctuation">(</span>int num1, int num2, int *sum<span class="token punctuation">)</span><span class="token punctuation">;</span>
int ns__sub<span class="token punctuation">(</span>int num1, int num2, int *sum<span class="token punctuation">)</span><span class="token punctuation">;</span>

<span class="token comment"># &#x4E0D;&#x8981;&#x4F7F;&#x7528;STL&#x4EE3;&#x7801;,&#x5E76;&#x751F;&#x6210;c&#x4EE3;&#x7801;</span>
$ wsdl2h -sc <span class="token punctuation">[</span>-t typemap.dat<span class="token punctuation">]</span> -o calc.h calc.wsdl 
<span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></pre></li>
</ul>
<h5 class="mume-header undefined" id="H-3-1-1-2">3.1.1.2 &#x7F16;&#x8F91;&#x670D;&#x52A1;&#x7AEF;&#x6D4B;&#x8BD5;&#x6587;&#x4EF6;: <code>test_calc_server.c</code></h5>

<pre data-role="codeBlock" data-info="c {.line-numbers}" class="language-c line-numbers"><span class="token macro property"><span class="token directive-hash">#</span><span class="token directive keyword">include</span> <span class="token string">&quot;soapH.h&quot;</span></span>
<span class="token macro property"><span class="token directive-hash">#</span><span class="token directive keyword">include</span> <span class="token string">&quot;yyy.nsmap&quot;</span></span>

<span class="token keyword keyword-int">int</span> <span class="token function">main</span><span class="token punctuation">(</span><span class="token keyword keyword-int">int</span> argc<span class="token punctuation">,</span> <span class="token keyword keyword-char">char</span> <span class="token operator">*</span><span class="token operator">*</span>argv<span class="token punctuation">)</span>
<span class="token punctuation">{</span>
    <span class="token keyword keyword-int">int</span> m<span class="token punctuation">,</span> s<span class="token punctuation">;</span>               <span class="token comment">/* master and slave sockets */</span>
    <span class="token keyword keyword-struct">struct</span> <span class="token class-name">soap</span> SmsWBS_soap<span class="token punctuation">;</span>

    <span class="token function">soap_init</span><span class="token punctuation">(</span><span class="token operator">&amp;</span>SmsWBS_soap<span class="token punctuation">)</span><span class="token punctuation">;</span>

    <span class="token function">soap_set_namespaces</span><span class="token punctuation">(</span><span class="token operator">&amp;</span>SmsWBS_soap<span class="token punctuation">,</span> namespaces<span class="token punctuation">)</span><span class="token punctuation">;</span>

    <span class="token keyword keyword-if">if</span> <span class="token punctuation">(</span>argc <span class="token operator">&lt;</span> <span class="token number">2</span><span class="token punctuation">)</span>
    <span class="token punctuation">{</span>
        <span class="token function">printf</span><span class="token punctuation">(</span><span class="token string">&quot;usage: %s &lt;server_port&gt; \n&quot;</span><span class="token punctuation">,</span> argv<span class="token punctuation">[</span><span class="token number">0</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token function">exit</span><span class="token punctuation">(</span><span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
    <span class="token keyword keyword-else">else</span>
    <span class="token punctuation">{</span>
        m <span class="token operator">=</span> <span class="token function">soap_bind</span><span class="token punctuation">(</span><span class="token operator">&amp;</span>SmsWBS_soap<span class="token punctuation">,</span> <span class="token constant">NULL</span><span class="token punctuation">,</span> <span class="token function">atoi</span><span class="token punctuation">(</span>argv<span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token number">100</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token keyword keyword-if">if</span> <span class="token punctuation">(</span>m <span class="token operator">&lt;</span> <span class="token number">0</span><span class="token punctuation">)</span>
        <span class="token punctuation">{</span>
            <span class="token function">soap_print_fault</span><span class="token punctuation">(</span><span class="token operator">&amp;</span>SmsWBS_soap<span class="token punctuation">,</span> <span class="token constant">stderr</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token function">exit</span><span class="token punctuation">(</span><span class="token operator">-</span><span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span>

        <span class="token function">fprintf</span><span class="token punctuation">(</span><span class="token constant">stderr</span><span class="token punctuation">,</span> <span class="token string">&quot;Socket connection successful: master socket = %d\n&quot;</span><span class="token punctuation">,</span> m<span class="token punctuation">)</span><span class="token punctuation">;</span>

        <span class="token keyword keyword-for">for</span> <span class="token punctuation">(</span><span class="token punctuation">;</span><span class="token punctuation">;</span><span class="token punctuation">)</span>
        <span class="token punctuation">{</span>
            s <span class="token operator">=</span> <span class="token function">soap_accept</span><span class="token punctuation">(</span><span class="token operator">&amp;</span>SmsWBS_soap<span class="token punctuation">)</span><span class="token punctuation">;</span>

            <span class="token keyword keyword-if">if</span> <span class="token punctuation">(</span>s <span class="token operator">&lt;</span> <span class="token number">0</span><span class="token punctuation">)</span>
            <span class="token punctuation">{</span>
                <span class="token function">soap_print_fault</span><span class="token punctuation">(</span><span class="token operator">&amp;</span>SmsWBS_soap<span class="token punctuation">,</span> <span class="token constant">stderr</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
                <span class="token function">exit</span><span class="token punctuation">(</span><span class="token operator">-</span><span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token punctuation">}</span>

            <span class="token function">fprintf</span><span class="token punctuation">(</span><span class="token constant">stderr</span><span class="token punctuation">,</span> <span class="token string">&quot;Socket connection successful: slave socket = %d\n&quot;</span><span class="token punctuation">,</span> s<span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token function">soap_serve</span><span class="token punctuation">(</span><span class="token operator">&amp;</span>SmsWBS_soap<span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token function">soap_end</span><span class="token punctuation">(</span><span class="token operator">&amp;</span>SmsWBS_soap<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span>

    <span class="token punctuation">}</span>

    <span class="token keyword keyword-return">return</span> <span class="token number">0</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>

<span class="token keyword keyword-int">int</span> <span class="token function">ns__add</span><span class="token punctuation">(</span><span class="token keyword keyword-struct">struct</span> <span class="token class-name">soap</span> <span class="token operator">*</span>add_soap<span class="token punctuation">,</span> <span class="token keyword keyword-int">int</span> num1<span class="token punctuation">,</span> <span class="token keyword keyword-int">int</span> num2<span class="token punctuation">,</span> <span class="token keyword keyword-int">int</span> <span class="token operator">*</span>sum<span class="token punctuation">)</span>
<span class="token punctuation">{</span>
    <span class="token operator">*</span>sum <span class="token operator">=</span> num1 <span class="token operator">+</span> num2<span class="token punctuation">;</span>
    <span class="token keyword keyword-return">return</span> <span class="token number">0</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>    
<span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></pre><ul>
<li>&#x8BF4;&#x660E;:
<ul>
<li>&#x6D41;&#x7A0B;&#x7C7B;&#x4F3C;socket&#x6D41;&#x7A0B;<br>
<code>soap_init</code> --&gt; <code>soap_bind</code> --&gt; <code>while(1){soap_accept}</code> --&gt; <code>soap_serve</code> --&gt;<code>soap_end</code><br>
&#x521D;&#x59CB;&#x5316;&#xFF0C;&#x7ED1;&#x5B9A;&#xFF08;&#x4F20;&#x5165;&#x7684;argv&#x4E2D;&#x6709;&#x8981;&#x76D1;&#x542C;&#x7684;&#x7AEF;&#x53E3;&#x53F7;&#xFF09;&#xFF0C;&#x76D1;&#x542C;&#x63A5;&#x6536;&#xFF0C;&#x91CA;&#x653E;&#x3002;</li>
</ul>
</li>
</ul>
<h5 class="mume-header undefined" id="H-3-1-1-3">3.1.1.3 &#x7F16;&#x8F91;&#x5BA2;&#x6237;&#x7AEF;&#x6587;&#x4EF6;: <code>test_calc_client.c</code></h5>

<pre data-role="codeBlock" data-info="c {.line-numbers}" class="language-c line-numbers"><span class="token macro property"><span class="token directive-hash">#</span><span class="token directive keyword">include</span> <span class="token string">&lt;stdio.h&gt;</span></span>
<span class="token macro property"><span class="token directive-hash">#</span><span class="token directive keyword">include</span> <span class="token string">&lt;stdlib.h&gt;</span></span>
<span class="token macro property"><span class="token directive-hash">#</span><span class="token directive keyword">include</span> <span class="token string">&quot;soapStub.h&quot;</span></span>
<span class="token macro property"><span class="token directive-hash">#</span><span class="token directive keyword">include</span> <span class="token string">&quot;yyy.nsmap&quot;</span></span>

<span class="token keyword keyword-int">int</span> <span class="token function">add</span><span class="token punctuation">(</span><span class="token keyword keyword-const">const</span> <span class="token keyword keyword-char">char</span> <span class="token operator">*</span>server<span class="token punctuation">,</span> <span class="token keyword keyword-int">int</span> num1<span class="token punctuation">,</span> <span class="token keyword keyword-int">int</span> num2<span class="token punctuation">,</span> <span class="token keyword keyword-int">int</span> <span class="token operator">*</span>sum<span class="token punctuation">)</span><span class="token punctuation">;</span>

<span class="token keyword keyword-int">int</span> <span class="token function">add</span><span class="token punctuation">(</span><span class="token keyword keyword-const">const</span> <span class="token keyword keyword-char">char</span> <span class="token operator">*</span>server<span class="token punctuation">,</span> <span class="token keyword keyword-int">int</span> num1<span class="token punctuation">,</span> <span class="token keyword keyword-int">int</span> num2<span class="token punctuation">,</span> <span class="token keyword keyword-int">int</span> <span class="token operator">*</span>sum<span class="token punctuation">)</span>
<span class="token punctuation">{</span>
    <span class="token keyword keyword-struct">struct</span> <span class="token class-name">soap</span> SmsWBS_soap<span class="token punctuation">;</span>
    <span class="token keyword keyword-int">int</span> result <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span>

    <span class="token function">soap_init</span><span class="token punctuation">(</span><span class="token operator">&amp;</span>SmsWBS_soap<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token function">soap_set_namespaces</span><span class="token punctuation">(</span><span class="token operator">&amp;</span>SmsWBS_soap<span class="token punctuation">,</span> namespaces<span class="token punctuation">)</span><span class="token punctuation">;</span>

    <span class="token function">soap_call_ns__add</span><span class="token punctuation">(</span><span class="token operator">&amp;</span>SmsWBS_soap<span class="token punctuation">,</span> server<span class="token punctuation">,</span> <span class="token string">&quot;&quot;</span><span class="token punctuation">,</span> num1<span class="token punctuation">,</span> num2<span class="token punctuation">,</span> sum<span class="token punctuation">)</span><span class="token punctuation">;</span>

    <span class="token keyword keyword-if">if</span><span class="token punctuation">(</span>SmsWBS_soap<span class="token punctuation">.</span>error<span class="token punctuation">)</span>
    <span class="token punctuation">{</span>
        <span class="token function">printf</span><span class="token punctuation">(</span><span class="token string">&quot;soap error:%d, %s, %s &quot;</span><span class="token punctuation">,</span> SmsWBS_soap<span class="token punctuation">.</span>error<span class="token punctuation">,</span> <span class="token operator">*</span><span class="token function">soap_faultcode</span><span class="token punctuation">(</span><span class="token operator">&amp;</span>SmsWBS_soap<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token operator">*</span><span class="token function">soap_faultstring</span><span class="token punctuation">(</span><span class="token operator">&amp;</span>SmsWBS_soap<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        result <span class="token operator">=</span> SmsWBS_soap<span class="token punctuation">.</span>error<span class="token punctuation">;</span>
    <span class="token punctuation">}</span>

    <span class="token function">soap_end</span><span class="token punctuation">(</span><span class="token operator">&amp;</span>SmsWBS_soap<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token function">soap_done</span><span class="token punctuation">(</span><span class="token operator">&amp;</span>SmsWBS_soap<span class="token punctuation">)</span><span class="token punctuation">;</span>

    <span class="token keyword keyword-return">return</span> result<span class="token punctuation">;</span>
<span class="token punctuation">}</span>

<span class="token keyword keyword-int">int</span> <span class="token function">main</span><span class="token punctuation">(</span><span class="token keyword keyword-int">int</span> argc<span class="token punctuation">,</span> <span class="token keyword keyword-char">char</span> <span class="token operator">*</span><span class="token operator">*</span>argv<span class="token punctuation">)</span>
<span class="token punctuation">{</span>
    <span class="token keyword keyword-int">int</span> result <span class="token operator">=</span> <span class="token operator">-</span><span class="token number">1</span><span class="token punctuation">;</span>
    <span class="token keyword keyword-const">const</span> <span class="token keyword keyword-char">char</span><span class="token operator">*</span> server<span class="token operator">=</span><span class="token string">&quot;http://localhost:9000&quot;</span><span class="token punctuation">;</span>

    <span class="token keyword keyword-int">int</span> num1 <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span>
    <span class="token keyword keyword-int">int</span> num2 <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span>
    <span class="token keyword keyword-int">int</span> sum <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span>

    <span class="token keyword keyword-if">if</span><span class="token punctuation">(</span> argc <span class="token operator">&lt;</span> <span class="token number">3</span> <span class="token punctuation">)</span>
    <span class="token punctuation">{</span>
        <span class="token function">printf</span><span class="token punctuation">(</span><span class="token string">&quot;usage: %s num1 num2 \n&quot;</span><span class="token punctuation">,</span> argv<span class="token punctuation">[</span><span class="token number">0</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token function">exit</span><span class="token punctuation">(</span><span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

    <span class="token punctuation">}</span>

    num1 <span class="token operator">=</span> <span class="token function">atoi</span><span class="token punctuation">(</span>argv<span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    num2 <span class="token operator">=</span> <span class="token function">atoi</span><span class="token punctuation">(</span>argv<span class="token punctuation">[</span><span class="token number">2</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

    result <span class="token operator">=</span> <span class="token function">add</span><span class="token punctuation">(</span>server<span class="token punctuation">,</span> num1<span class="token punctuation">,</span> num2<span class="token punctuation">,</span> <span class="token operator">&amp;</span>sum<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token keyword keyword-if">if</span> <span class="token punctuation">(</span>result <span class="token operator">!=</span> <span class="token number">0</span><span class="token punctuation">)</span>
    <span class="token punctuation">{</span>
        <span class="token function">printf</span><span class="token punctuation">(</span><span class="token string">&quot;soap err, errcode = %d \n&quot;</span><span class="token punctuation">,</span> result<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
    <span class="token keyword keyword-else">else</span>
    <span class="token punctuation">{</span>
        <span class="token function">printf</span><span class="token punctuation">(</span><span class="token string">&quot;%d + %d = %d \n&quot;</span><span class="token punctuation">,</span> num1<span class="token punctuation">,</span> num2<span class="token punctuation">,</span> sum<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>

    <span class="token keyword keyword-return">return</span> <span class="token number">0</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>    
<span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></pre><h5 class="mume-header undefined" id="H-3-1-1-4">3.1.1.4 &#x7F16;&#x8F91;<code>Makefile</code></h5>

<pre data-role="codeBlock" data-info="makefile {.line-numbers}" class="language-makefile line-numbers">GSOAP_ROOT<span class="token operator">=</span>/usr/local/gSOAP
WSNAME0<span class="token operator">=</span>soap
WSNAME<span class="token operator">=</span>yyy
CC<span class="token operator">=</span>g++ -g -DWITH_NONAMESPACES
INCLUDE<span class="token operator">=</span>-I <span class="token variable">$</span><span class="token punctuation">(</span>GSOAP_ROOT<span class="token punctuation">)</span>/<span class="token keyword keyword-include">include</span>
SERVER_OBJS<span class="token operator">=</span><span class="token variable">$</span><span class="token punctuation">(</span>WSNAME0<span class="token punctuation">)</span>C.o <span class="token variable">$</span><span class="token punctuation">(</span>WSNAME0<span class="token punctuation">)</span>Server.o stdsoap2.o
CLIENT_OBJS<span class="token operator">=</span><span class="token variable">$</span><span class="token punctuation">(</span>GSOAP_ROOT<span class="token punctuation">)</span>/env/envC.o <span class="token variable">$</span><span class="token punctuation">(</span>WSNAME0<span class="token punctuation">)</span>ClientLib.o stdsoap2.o
ALL_OBJS<span class="token operator">=</span><span class="token variable">$</span><span class="token punctuation">{</span>WSNAME<span class="token punctuation">}</span>server.o <span class="token variable">$</span><span class="token punctuation">(</span>WSNAME0<span class="token punctuation">)</span>C.o <span class="token variable">$</span><span class="token punctuation">(</span>WSNAME0<span class="token punctuation">)</span>Server.o <span class="token variable">$</span><span class="token punctuation">{</span>WSNAME<span class="token punctuation">}</span>test.o <span class="token variable">$</span><span class="token punctuation">(</span>WSNAME0<span class="token punctuation">)</span>ClientLib.o
<span class="token comment">#GSOAP_SRC=/usr/local/gsoap-2.7/gsoap</span>

<span class="token symbol">all</span><span class="token punctuation">:</span>server

<span class="token symbol"><span class="token variable">$</span>{WSNAME}.wsdl</span><span class="token punctuation">:</span><span class="token variable">$</span><span class="token punctuation">{</span>WSNAME<span class="token punctuation">}</span>.h
        <span class="token variable">$</span><span class="token punctuation">(</span>GSOAP_ROOT<span class="token punctuation">)</span>/bin/soapcpp2 -c <span class="token variable">$</span><span class="token punctuation">(</span>GSOAP_ROOT<span class="token punctuation">)</span>/import <span class="token variable">$</span><span class="token punctuation">{</span>WSNAME<span class="token punctuation">}</span>.h

<span class="token symbol">stdsoap2.o</span><span class="token punctuation">:</span><span class="token variable">$</span><span class="token punctuation">(</span>GSOAP_ROOT<span class="token punctuation">)</span>/src/stdsoap2.c
        <span class="token variable">$</span><span class="token punctuation">(</span>CC<span class="token punctuation">)</span> -c <span class="token variable">$?</span> <span class="token variable">$</span><span class="token punctuation">(</span>INCLUDE<span class="token punctuation">)</span>

<span class="token symbol"><span class="token variable">$</span>(ALL_OBJS)</span><span class="token punctuation">:</span>%.o<span class="token punctuation">:</span>%.c
        <span class="token variable">$</span><span class="token punctuation">(</span>CC<span class="token punctuation">)</span> -c <span class="token variable">$?</span> <span class="token variable">$</span><span class="token punctuation">(</span>INCLUDE<span class="token punctuation">)</span>

<span class="token symbol">server</span><span class="token punctuation">:</span>Makefile <span class="token variable">$</span><span class="token punctuation">{</span>WSNAME<span class="token punctuation">}</span>.wsdl <span class="token variable">$</span><span class="token punctuation">{</span>WSNAME<span class="token punctuation">}</span>server.o <span class="token variable">$</span><span class="token punctuation">(</span>SERVER_OBJS<span class="token punctuation">)</span>
        <span class="token variable">$</span><span class="token punctuation">(</span>CC<span class="token punctuation">)</span> <span class="token variable">$</span><span class="token punctuation">{</span>WSNAME<span class="token punctuation">}</span>server.o <span class="token variable">$</span><span class="token punctuation">(</span>SERVER_OBJS<span class="token punctuation">)</span> -o <span class="token variable">$</span><span class="token punctuation">{</span>WSNAME<span class="token punctuation">}</span>server

<span class="token symbol">client</span><span class="token punctuation">:</span>Makefile <span class="token variable">$</span><span class="token punctuation">{</span>WSNAME<span class="token punctuation">}</span>.wsdl <span class="token variable">$</span><span class="token punctuation">{</span>WSNAME<span class="token punctuation">}</span>test.c <span class="token variable">$</span><span class="token punctuation">(</span>ALL_OBJS<span class="token punctuation">)</span> stdsoap2.o
        <span class="token variable">$</span><span class="token punctuation">(</span>CC<span class="token punctuation">)</span> <span class="token variable">$</span><span class="token punctuation">{</span>WSNAME<span class="token punctuation">}</span>test.o <span class="token variable">$</span><span class="token punctuation">(</span>CLIENT_OBJS<span class="token punctuation">)</span> -o <span class="token variable">$</span><span class="token punctuation">{</span>WSNAME<span class="token punctuation">}</span>test

<span class="token symbol">clean</span><span class="token punctuation">:</span>
        rm -f *.o *.xml *.a *.wsdl *.nsmap <span class="token variable">$</span><span class="token punctuation">(</span>WSNAME0<span class="token punctuation">)</span>H.h <span class="token variable">$</span><span class="token punctuation">(</span>WSNAME0<span class="token punctuation">)</span>C.c <span class="token variable">$</span><span class="token punctuation">(</span>WSNAME0<span class="token punctuation">)</span>Server.c <span class="token variable">$</span><span class="token punctuation">(</span>WSNAME0<span class="token punctuation">)</span>Client.c \
        <span class="token variable">$</span><span class="token punctuation">(</span>WSNAME0<span class="token punctuation">)</span>Stub.* <span class="token variable">$</span><span class="token punctuation">(</span>WSNAME<span class="token punctuation">)</span><span class="token variable">$</span><span class="token punctuation">(</span>WSNAME<span class="token punctuation">)</span>Proxy.* <span class="token variable">$</span><span class="token punctuation">(</span>WSNAME<span class="token punctuation">)</span><span class="token variable">$</span><span class="token punctuation">(</span>WSNAME<span class="token punctuation">)</span>Object.* \
        <span class="token variable">$</span><span class="token punctuation">(</span>WSNAME0<span class="token punctuation">)</span>ServerLib.c <span class="token variable">$</span><span class="token punctuation">(</span>WSNAME0<span class="token punctuation">)</span>ClientLib.c <span class="token variable">$</span><span class="token punctuation">(</span>WSNAME<span class="token punctuation">)</span>server ns.xsd <span class="token variable">$</span><span class="token punctuation">(</span>WSNAME<span class="token punctuation">)</span>test    
<span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></pre><h5 class="mume-header undefined" id="H-3-1-1-5">3.1.1.5 &#x7F16;&#x8BD1;&#x53CA;&#x8FD0;&#x884C;</h5>

<ul>
<li>&#x7F16;&#x8BD1;<pre data-role="codeBlock" data-info="shell {.line-numbers}" class="language-shell line-numbers"><span class="token comment"># &#x751F;&#x6210;&#x670D;&#x52A1;&#x7AEF;&#x7A0B;&#x5E8F;:</span>
$ <span class="token function">make</span> 
<span class="token comment"># &#x751F;&#x6210;&#x670D;&#x52A1;&#x7AEF;&#x6D4B;&#x8BD5;&#x7A0B;&#x5E8F;(&#x5BA2;&#x6237;&#x7AEF;&#x7A0B;&#x5E8F;??):</span>
$ <span class="token function">make</span> client
<span class="token comment"># $ ls </span>
<span class="token comment"># Makefile  soapC.c       soapClientLib.c  soapServer.c     soapStub.h       yyy.add.res.xml  yyy.nsmap  yyyserver.c  yyytest.c</span>
<span class="token comment"># ns.xsd    soapClient.c  soapH.h          soapServerLib.c  yyy.add.req.xml  yyy.h            yyyserver  yyytest      yyy.wsdl    </span>
<span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></pre></li>
<li>&#x8FD0;&#x884C;<pre data-role="codeBlock" data-info="shell {.line-numbers}" class="language-shell line-numbers"><span class="token comment"># &#x670D;&#x52A1;&#x7AEF;</span>
$ ./yyyserver <span class="token number">9000</span>
Socket connection successful: master socket <span class="token operator">=</span> <span class="token number">3</span>

<span class="token comment"># &#x5BA2;&#x6237;&#x7AEF;</span>
$ /yyytest <span class="token number">1</span> <span class="token number">100</span>
<span class="token number">1</span> + <span class="token number">100</span> <span class="token operator">=</span> <span class="token number">101</span> 

<span class="token comment"># &#x89C2;&#x5BDF;&#x670D;&#x52A1;&#x7AEF;&#x65E5;&#x5FD7;&#xFF0C;&#x6B64;&#x65F6;&#x4F1A;&#x591A;&#x8F93;&#x51FA;&#x4E00;&#x884C;&#x65E5;&#x5FD7;</span>
<span class="token punctuation">..</span>. <span class="token punctuation">..</span>.
Socket connection successful: slave socket <span class="token operator">=</span> <span class="token number">4</span>
<span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></pre></li>
</ul>
<h5 class="mume-header undefined" id="H-3-1-1-6">3.1.1.6 &#x6D4B;&#x8BD5;GET&#x63A5;&#x53E3;</h5>

<p>&#x670D;&#x52A1;&#x7AEF;&#x7A0B;&#x5E8F;&#x5F00;&#x542F;&#x540E;&#xFF0C;&#x5728;&#x5BA2;&#x6237;&#x7AEF;&#x6267;&#x884C;<code>curl</code>&#x547D;&#x4EE4;&#x6216;&#x5728;&#x672C;&#x5730;&#x53CA;&#x8FDC;&#x7A0B;&#x7684;&#x6D4F;&#x89C8;&#x5668;&#x5730;&#x5740;&#x680F;&#x5185;&#x8F93;&#x5165;<code>http://10.10.90.46:9000</code>&#xFF0C;&#x7ED3;&#x679C;&#x5982;&#x4E0B;:</p>
<pre data-role="codeBlock" data-info="xml {.line-numbers}" class="language-xml line-numbers"><span class="token prolog">&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;</span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token namespace">SOAP-ENV:</span>Envelope</span>
    <span class="token attr-name"><span class="token namespace">xmlns:</span>SOAP-ENV</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>http://schemas.xmlsoap.org/soap/envelope/<span class="token punctuation">&quot;</span></span>
    <span class="token attr-name"><span class="token namespace">xmlns:</span>SOAP-ENC</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>http://schemas.xmlsoap.org/soap/encoding/<span class="token punctuation">&quot;</span></span>
    <span class="token attr-name"><span class="token namespace">xmlns:</span>xsi</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>http://www.w3.org/2001/XMLSchema-instance<span class="token punctuation">&quot;</span></span>
    <span class="token attr-name"><span class="token namespace">xmlns:</span>xsd</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>http://www.w3.org/2001/XMLSchema<span class="token punctuation">&quot;</span></span>
    <span class="token attr-name"><span class="token namespace">xmlns:</span>ns</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>urn:zzz<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token namespace">SOAP-ENV:</span>Body</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token namespace">SOAP-ENV:</span>Fault</span><span class="token punctuation">&gt;</span></span>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>faultcode</span><span class="token punctuation">&gt;</span></span>SOAP-ENV:Client<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>faultcode</span><span class="token punctuation">&gt;</span></span>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>faultstring</span><span class="token punctuation">&gt;</span></span>HTTP GET method not implemented<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>faultstring</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token namespace">SOAP-ENV:</span>Fault</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token namespace">SOAP-ENV:</span>Body</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token namespace">SOAP-ENV:</span>Envelope</span><span class="token punctuation">&gt;</span></span>
<span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></pre><ul>
<li>&#x63D0;&#x793A;<br>
&#x4ECE;&#x54CD;&#x5E94;&#x7ED3;&#x679C;&#x6765;&#x770B;&#xFF0C;&#x63D0;&#x793A;: HTTP GET method not implemented.</li>
</ul>
<p>&#x7EE7;&#x7EED;&#x5B8C;&#x5584;&#x7A0B;&#x5E8F;&#x589E;&#x52A0;<code>http_get</code>&#x5904;&#x7406;&#x63A5;&#x53E3;:</p>
<pre data-role="codeBlock" data-info="c {.line-numbers}" class="language-c line-numbers">$ cat yyyserver<span class="token punctuation">.</span>c
<span class="token macro property"><span class="token directive-hash">#</span><span class="token directive keyword">include</span> <span class="token string">&quot;soapH.h&quot;</span></span>
<span class="token macro property"><span class="token directive-hash">#</span><span class="token directive keyword">include</span> <span class="token string">&quot;yyy.nsmap&quot;</span></span>

<span class="token keyword keyword-extern">extern</span> <span class="token keyword keyword-int">int</span> <span class="token function">http_get</span><span class="token punctuation">(</span><span class="token keyword keyword-struct">struct</span> <span class="token class-name">soap</span>   <span class="token operator">*</span>soap<span class="token punctuation">)</span> <span class="token punctuation">;</span>
<span class="token keyword keyword-int">int</span> <span class="token function">main</span><span class="token punctuation">(</span><span class="token keyword keyword-int">int</span> argc<span class="token punctuation">,</span> <span class="token keyword keyword-char">char</span> <span class="token operator">*</span><span class="token operator">*</span>argv<span class="token punctuation">)</span>
<span class="token punctuation">{</span>
    <span class="token keyword keyword-int">int</span> m<span class="token punctuation">,</span> s<span class="token punctuation">;</span>               <span class="token comment">/* master and slave sockets */</span>
    <span class="token keyword keyword-struct">struct</span> <span class="token class-name">soap</span> yyy_soap<span class="token punctuation">;</span>

    <span class="token function">soap_init</span><span class="token punctuation">(</span><span class="token operator">&amp;</span>yyy_soap<span class="token punctuation">)</span><span class="token punctuation">;</span>

    <span class="token function">soap_set_namespaces</span><span class="token punctuation">(</span><span class="token operator">&amp;</span>yyy_soap<span class="token punctuation">,</span> namespaces<span class="token punctuation">)</span><span class="token punctuation">;</span>

    <span class="token keyword keyword-if">if</span> <span class="token punctuation">(</span>argc <span class="token operator">&lt;</span> <span class="token number">2</span><span class="token punctuation">)</span>
    <span class="token punctuation">{</span>
        <span class="token function">printf</span><span class="token punctuation">(</span><span class="token string">&quot;usage: %s &lt;server_port&gt; \n&quot;</span><span class="token punctuation">,</span> argv<span class="token punctuation">[</span><span class="token number">0</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token function">exit</span><span class="token punctuation">(</span><span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>

    yyy_soap<span class="token punctuation">.</span>fget <span class="token operator">=</span> http_get<span class="token punctuation">;</span>
    m <span class="token operator">=</span> <span class="token function">soap_bind</span><span class="token punctuation">(</span><span class="token operator">&amp;</span>yyy_soap<span class="token punctuation">,</span> <span class="token constant">NULL</span><span class="token punctuation">,</span> <span class="token function">atoi</span><span class="token punctuation">(</span>argv<span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token number">100</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token keyword keyword-if">if</span> <span class="token punctuation">(</span>m <span class="token operator">&lt;</span> <span class="token number">0</span><span class="token punctuation">)</span>
    <span class="token punctuation">{</span>
        <span class="token function">soap_print_fault</span><span class="token punctuation">(</span><span class="token operator">&amp;</span>yyy_soap<span class="token punctuation">,</span> <span class="token constant">stderr</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token function">exit</span><span class="token punctuation">(</span><span class="token operator">-</span><span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>

    <span class="token function">fprintf</span><span class="token punctuation">(</span><span class="token constant">stderr</span><span class="token punctuation">,</span> <span class="token string">&quot;Socket connection successful: master socket = %d\n&quot;</span><span class="token punctuation">,</span> m<span class="token punctuation">)</span><span class="token punctuation">;</span>

    <span class="token keyword keyword-for">for</span> <span class="token punctuation">(</span><span class="token punctuation">;</span><span class="token punctuation">;</span><span class="token punctuation">)</span>
    <span class="token punctuation">{</span>
        s <span class="token operator">=</span> <span class="token function">soap_accept</span><span class="token punctuation">(</span><span class="token operator">&amp;</span>yyy_soap<span class="token punctuation">)</span><span class="token punctuation">;</span>

        <span class="token keyword keyword-if">if</span> <span class="token punctuation">(</span>s <span class="token operator">&lt;</span> <span class="token number">0</span><span class="token punctuation">)</span>
        <span class="token punctuation">{</span>
            <span class="token function">soap_print_fault</span><span class="token punctuation">(</span><span class="token operator">&amp;</span>yyy_soap<span class="token punctuation">,</span> <span class="token constant">stderr</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token function">exit</span><span class="token punctuation">(</span><span class="token operator">-</span><span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span>

        <span class="token function">fprintf</span><span class="token punctuation">(</span><span class="token constant">stderr</span><span class="token punctuation">,</span> <span class="token string">&quot;Socket connection successful: slave socket = %d\n&quot;</span><span class="token punctuation">,</span> s<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token function">soap_serve</span><span class="token punctuation">(</span><span class="token operator">&amp;</span>yyy_soap<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token function">soap_end</span><span class="token punctuation">(</span><span class="token operator">&amp;</span>yyy_soap<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>

    <span class="token keyword keyword-return">return</span> <span class="token number">0</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>

<span class="token keyword keyword-int">int</span> <span class="token function">ns__add</span><span class="token punctuation">(</span><span class="token keyword keyword-struct">struct</span> <span class="token class-name">soap</span> <span class="token operator">*</span>add_soap<span class="token punctuation">,</span> <span class="token keyword keyword-int">int</span> num1<span class="token punctuation">,</span> <span class="token keyword keyword-int">int</span> num2<span class="token punctuation">,</span> <span class="token keyword keyword-int">int</span> <span class="token operator">*</span>sum<span class="token punctuation">)</span>
<span class="token punctuation">{</span>
    <span class="token operator">*</span>sum <span class="token operator">=</span> num1 <span class="token operator">+</span> num2<span class="token punctuation">;</span>
    <span class="token keyword keyword-return">return</span> <span class="token number">0</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>

<span class="token keyword keyword-int">int</span> <span class="token function">http_get</span><span class="token punctuation">(</span><span class="token keyword keyword-struct">struct</span> <span class="token class-name">soap</span>   <span class="token operator">*</span>soap<span class="token punctuation">)</span> 
<span class="token punctuation">{</span> 
    FILE<span class="token operator">*</span>fd <span class="token operator">=</span> <span class="token constant">NULL</span><span class="token punctuation">;</span>
    fd <span class="token operator">=</span> <span class="token function">fopen</span><span class="token punctuation">(</span><span class="token string">&quot;yyy.wsdl&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;rb&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">//open WSDL file to copy</span>
    <span class="token keyword keyword-if">if</span> <span class="token punctuation">(</span><span class="token operator">!</span>fd<span class="token punctuation">)</span>
    <span class="token punctuation">{</span>
        <span class="token keyword keyword-return">return</span> <span class="token number">404</span><span class="token punctuation">;</span> <span class="token comment">//return HTTP not found error</span>
    <span class="token punctuation">}</span>
    soap<span class="token operator">-&gt;</span>http_content <span class="token operator">=</span> <span class="token string">&quot;text/xml&quot;</span><span class="token punctuation">;</span>  <span class="token comment">//HTTP header with text /xml content</span>
    <span class="token function">soap_response</span><span class="token punctuation">(</span>soap<span class="token punctuation">,</span>SOAP_FILE<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token keyword keyword-for">for</span><span class="token punctuation">(</span><span class="token punctuation">;</span><span class="token punctuation">;</span><span class="token punctuation">)</span>
    <span class="token punctuation">{</span>
        <span class="token class-name">size_t</span> r <span class="token operator">=</span> <span class="token function">fread</span><span class="token punctuation">(</span>soap<span class="token operator">-&gt;</span>tmpbuf<span class="token punctuation">,</span><span class="token number">1</span><span class="token punctuation">,</span> <span class="token keyword keyword-sizeof">sizeof</span><span class="token punctuation">(</span>soap<span class="token operator">-&gt;</span>tmpbuf<span class="token punctuation">)</span><span class="token punctuation">,</span> fd<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token keyword keyword-if">if</span> <span class="token punctuation">(</span><span class="token operator">!</span>r<span class="token punctuation">)</span>
        <span class="token punctuation">{</span>
            <span class="token keyword keyword-break">break</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span>
        <span class="token keyword keyword-if">if</span> <span class="token punctuation">(</span><span class="token function">soap_send_raw</span><span class="token punctuation">(</span>soap<span class="token punctuation">,</span> soap<span class="token operator">-&gt;</span>tmpbuf<span class="token punctuation">,</span> r<span class="token punctuation">)</span><span class="token punctuation">)</span>
        <span class="token punctuation">{</span>
            <span class="token keyword keyword-break">break</span><span class="token punctuation">;</span> <span class="token comment">//cannot send, but little we can do about that</span>
        <span class="token punctuation">}</span>
    <span class="token punctuation">}</span>
    <span class="token function">fclose</span><span class="token punctuation">(</span>fd<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token function">soap_end_send</span><span class="token punctuation">(</span>soap<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token keyword keyword-return">return</span> SOAP_OK<span class="token punctuation">;</span> 
<span class="token punctuation">}</span> 
<span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></pre><p>&#x91CD;&#x65B0;<code>make</code>&#xFF0C;&#x7F16;&#x8BD1;&#x751F;&#x6210;<code>yyyserver</code>&#x540E;&#xFF0C;&#x91CD;&#x65B0;&#x8FDB;&#x884C;&#x6D4B;&#x8BD5;&#x3002;</p>
<ul>
<li>server<pre data-role="codeBlock" data-info="shell {.line-numbers}" class="language-shell line-numbers">$ ./yyyserver <span class="token number">9000</span>
<span aria-hidden="true" class="line-numbers-rows"><span></span></span></pre></li>
<li>client<pre data-role="codeBlock" data-info="shell {.line-numbers}" class="language-shell line-numbers">$ <span class="token function">curl</span> http://localhost:9000
<span aria-hidden="true" class="line-numbers-rows"><span></span></span></pre><ul>
<li>&#x63D0;&#x793A;:<br>
&#x5982;&#x679C;&#x662F;&#x8DE8;&#x673A;&#x5668;&#x6D4F;&#x89C8;&#x5668;&#x8BBF;&#x95EE;&#xFF0C;&#x8BB0;&#x5F97;&#x628A;&#x670D;&#x52A1;&#x7AEF;&#x9632;&#x706B;&#x5899;&#x7AEF;&#x53E3;&#x6253;&#x5F00;&#x3002;</li>
<li>&#x54CD;&#x5E94;&#x7ED3;&#x679C;<br>
&#x53EF;&#x770B;&#x51FA;&#x5BA2;&#x6237;&#x7AEF;&#x53EF;&#x6B63;&#x5E38;&#x83B7;&#x53D6;&#x5BA2;&#x6237;&#x7AEF;&#x8D44;&#x6E90;:<pre data-role="codeBlock" data-info="xml {.line-numbers}" class="language-xml line-numbers"><span class="token prolog">&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;</span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>definitions</span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>yyy<span class="token punctuation">&quot;</span></span>
  <span class="token attr-name">targetNamespace</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>http://10.10.90.46:9000/yyy.wsdl<span class="token punctuation">&quot;</span></span>
  <span class="token attr-name"><span class="token namespace">xmlns:</span>tns</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>http://10.10.90.46:9000/yyy.wsdl<span class="token punctuation">&quot;</span></span>
  <span class="token attr-name"><span class="token namespace">xmlns:</span>SOAP-ENV</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>http://schemas.xmlsoap.org/soap/envelope/<span class="token punctuation">&quot;</span></span>
  <span class="token attr-name"><span class="token namespace">xmlns:</span>SOAP-ENC</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>http://schemas.xmlsoap.org/soap/encoding/<span class="token punctuation">&quot;</span></span>
  <span class="token attr-name"><span class="token namespace">xmlns:</span>xsi</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>http://www.w3.org/2001/XMLSchema-instance<span class="token punctuation">&quot;</span></span>
  <span class="token attr-name"><span class="token namespace">xmlns:</span>xsd</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>http://www.w3.org/2001/XMLSchema<span class="token punctuation">&quot;</span></span>
  <span class="token attr-name"><span class="token namespace">xmlns:</span>ns</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>urn:yyy<span class="token punctuation">&quot;</span></span>
  <span class="token attr-name"><span class="token namespace">xmlns:</span>SOAP</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>http://schemas.xmlsoap.org/wsdl/soap/<span class="token punctuation">&quot;</span></span>
  <span class="token attr-name"><span class="token namespace">xmlns:</span>HTTP</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>http://schemas.xmlsoap.org/wsdl/http/<span class="token punctuation">&quot;</span></span>
  <span class="token attr-name"><span class="token namespace">xmlns:</span>MIME</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>http://schemas.xmlsoap.org/wsdl/mime/<span class="token punctuation">&quot;</span></span>
  <span class="token attr-name"><span class="token namespace">xmlns:</span>DIME</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>http://schemas.xmlsoap.org/ws/2002/04/dime/wsdl/<span class="token punctuation">&quot;</span></span>
  <span class="token attr-name"><span class="token namespace">xmlns:</span>WSDL</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>http://schemas.xmlsoap.org/wsdl/<span class="token punctuation">&quot;</span></span>
  <span class="token attr-name">xmlns</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>http://schemas.xmlsoap.org/wsdl/<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>

<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>types</span><span class="token punctuation">&gt;</span></span>

  <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>schema</span> <span class="token attr-name">targetNamespace</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>urn:yyy<span class="token punctuation">&quot;</span></span>
    <span class="token attr-name"><span class="token namespace">xmlns:</span>SOAP-ENV</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>http://schemas.xmlsoap.org/soap/envelope/<span class="token punctuation">&quot;</span></span>
    <span class="token attr-name"><span class="token namespace">xmlns:</span>SOAP-ENC</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>http://schemas.xmlsoap.org/soap/encoding/<span class="token punctuation">&quot;</span></span>
    <span class="token attr-name"><span class="token namespace">xmlns:</span>xsi</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>http://www.w3.org/2001/XMLSchema-instance<span class="token punctuation">&quot;</span></span>
    <span class="token attr-name"><span class="token namespace">xmlns:</span>xsd</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>http://www.w3.org/2001/XMLSchema<span class="token punctuation">&quot;</span></span>
    <span class="token attr-name"><span class="token namespace">xmlns:</span>ns</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>urn:yyy<span class="token punctuation">&quot;</span></span>
    <span class="token attr-name">xmlns</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>http://www.w3.org/2001/XMLSchema<span class="token punctuation">&quot;</span></span>
    <span class="token attr-name">elementFormDefault</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>unqualified<span class="token punctuation">&quot;</span></span>
    <span class="token attr-name">attributeFormDefault</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>unqualified<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>import</span> <span class="token attr-name">namespace</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>http://schemas.xmlsoap.org/soap/encoding/<span class="token punctuation">&quot;</span></span><span class="token punctuation">/&gt;</span></span>
  <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>schema</span><span class="token punctuation">&gt;</span></span>

<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>types</span><span class="token punctuation">&gt;</span></span>

<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>message</span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>addRequest<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
  <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>part</span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>num1<span class="token punctuation">&quot;</span></span> <span class="token attr-name">type</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>xsd:int<span class="token punctuation">&quot;</span></span><span class="token punctuation">/&gt;</span></span><span class="token comment">&lt;!-- ns__add::num1 --&gt;</span>
  <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>part</span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>num2<span class="token punctuation">&quot;</span></span> <span class="token attr-name">type</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>xsd:int<span class="token punctuation">&quot;</span></span><span class="token punctuation">/&gt;</span></span><span class="token comment">&lt;!-- ns__add::num2 --&gt;</span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>message</span><span class="token punctuation">&gt;</span></span>

<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>message</span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>addResponse<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
  <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>part</span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>sum<span class="token punctuation">&quot;</span></span> <span class="token attr-name">type</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>xsd:int<span class="token punctuation">&quot;</span></span><span class="token punctuation">/&gt;</span></span><span class="token comment">&lt;!-- ns__add::sum --&gt;</span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>message</span><span class="token punctuation">&gt;</span></span>

<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>portType</span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>yyyPortType<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
  <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>operation</span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>add<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>documentation</span><span class="token punctuation">&gt;</span></span>Service definition of function ns__add<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>documentation</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>input</span> <span class="token attr-name">message</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>tns:addRequest<span class="token punctuation">&quot;</span></span><span class="token punctuation">/&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>output</span> <span class="token attr-name">message</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>tns:addResponse<span class="token punctuation">&quot;</span></span><span class="token punctuation">/&gt;</span></span>
  <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>operation</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>portType</span><span class="token punctuation">&gt;</span></span>

<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>binding</span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>yyy<span class="token punctuation">&quot;</span></span> <span class="token attr-name">type</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>tns:yyyPortType<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
  <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token namespace">SOAP:</span>binding</span> <span class="token attr-name">style</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>rpc<span class="token punctuation">&quot;</span></span> <span class="token attr-name">transport</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>http://schemas.xmlsoap.org/soap/http<span class="token punctuation">&quot;</span></span><span class="token punctuation">/&gt;</span></span>
  <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>operation</span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>add<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token namespace">SOAP:</span>operation</span> <span class="token attr-name">style</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>rpc<span class="token punctuation">&quot;</span></span> <span class="token attr-name">soapAction</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span><span class="token punctuation">&quot;</span></span><span class="token punctuation">/&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>input</span><span class="token punctuation">&gt;</span></span>
          <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token namespace">SOAP:</span>body</span> <span class="token attr-name">use</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>encoded<span class="token punctuation">&quot;</span></span> <span class="token attr-name">encodingStyle</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>http://schemas.xmlsoap.org/soap/encoding/<span class="token punctuation">&quot;</span></span> <span class="token attr-name">namespace</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>urn:yyy<span class="token punctuation">&quot;</span></span><span class="token punctuation">/&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>input</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>output</span><span class="token punctuation">&gt;</span></span>
          <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token namespace">SOAP:</span>body</span> <span class="token attr-name">use</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>encoded<span class="token punctuation">&quot;</span></span> <span class="token attr-name">encodingStyle</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>http://schemas.xmlsoap.org/soap/encoding/<span class="token punctuation">&quot;</span></span> <span class="token attr-name">namespace</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>urn:yyy<span class="token punctuation">&quot;</span></span><span class="token punctuation">/&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>output</span><span class="token punctuation">&gt;</span></span>
  <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>operation</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>binding</span><span class="token punctuation">&gt;</span></span>

<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>service</span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>yyy<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
  <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>documentation</span><span class="token punctuation">&gt;</span></span>gSOAP 2.8.105 generated service definition<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>documentation</span><span class="token punctuation">&gt;</span></span>
  <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>port</span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>yyy<span class="token punctuation">&quot;</span></span> <span class="token attr-name">binding</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>tns:yyy<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token namespace">SOAP:</span>address</span> <span class="token attr-name">location</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>http://10.10.90.46:9000<span class="token punctuation">&quot;</span></span><span class="token punctuation">/&gt;</span></span>
  <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>port</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>service</span><span class="token punctuation">&gt;</span></span>

<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>definitions</span><span class="token punctuation">&gt;</span></span>    
<span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></pre></li>
</ul>
</li>
</ul>
<h4 class="mume-header undefined" id="H-3-1-2">3.1.2 C.2&#x7248;</h4>

<p>&#x524D;&#x63D0;&#xFF1A;gsoap&#x5E93;&#x7F16;&#x8BD1;&#x5E76;&#x79FB;&#x690D;&#x5B8C;&#x6BD5;&#x3002;</p>
<ol>
<li>&#x7F16;&#x8F91;wsdl&#x6587;&#x4EF6;&#x6216;&#x5B9A;&#x4E49;&#x4E00;&#x4E2A;&#x51FD;&#x6570;&#x58F0;&#x660E;&#x6587;&#x4EF6;&#xFF0C;&#x7528;&#x6765;&#x5B9A;&#x4E49;&#x63A5;&#x53E3;&#x51FD;&#x6570;&#xFF0C;&#x540D;&#x79F0;&#x4E3A;xxx.h<br>
wsdl&#x6587;&#x4EF6;&#x751F;&#x6210;xxx.h&#x6587;&#x4EF6;<pre data-role="codeBlock" data-info="shell {.line-numbers}" class="language-shell line-numbers">wsdl2h
//gsoapopt cw
//gsoap ns2 schema namespace: urn:xxx
//gsoap ns2 schema form: unqualified

//gsoap ns2 <span class="token function">service</span> name: xxx
//gsoap ns2 <span class="token function">service</span> type: xxxPortType
//gsoap ns2 <span class="token function">service</span> port:http://websrv.cs.fsu.edu/~engelen/xxxserver.cgi
//gsoap ns2 <span class="token function">service</span> namespace: urn:xxx
//gsoap ns2 <span class="token function">service</span> transport: http://schemas.xmlsoap.org/soap/http

//gsoap ns2  <span class="token function">service</span> method-protocol:   <span class="token function">add</span> SOAP
//gsoap ns2  <span class="token function">service</span> method-style:      <span class="token function">add</span> rpc
//gsoap ns2  <span class="token function">service</span> method-encoding:   <span class="token function">add</span> http://schemas.xmlsoap.org/soap/encoding/
//gsoap ns2  <span class="token function">service</span> method-action:     <span class="token function">add</span> <span class="token string">&quot;&quot;</span>
int ns2__add<span class="token punctuation">(</span> int num1, int num2, int* <span class="token function">sum</span> <span class="token punctuation">)</span><span class="token punctuation">;</span>

//gsoap ns2  <span class="token function">service</span> method-protocol:   sub SOAP
//gsoap ns2  <span class="token function">service</span> method-style:      sub rpc
//gsoap ns2  <span class="token function">service</span> method-encoding:   sub http://schemas.xmlsoap.org/soap/encoding/
//gsoap ns2  <span class="token function">service</span> method-action:     sub <span class="token string">&quot;&quot;</span>
int ns2__sub<span class="token punctuation">(</span> int num1, int num2, int* <span class="token function">sum</span> <span class="token punctuation">)</span><span class="token punctuation">;</span>    
<span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></pre></li>
<li>&#x6267;&#x884C;<code>soapcpp2</code>&#x547D;&#x4EE4;&#xFF0C;&#x81EA;&#x52A8;&#x751F;&#x6210;&#x4E00;&#x4E9B;&#x8FDC;&#x7A0B;&#x8C03;&#x7528;&#x9700;&#x8981;&#x7684;&#x6587;&#x4EF6;<pre data-role="codeBlock" data-info="shell {.line-numbers}" class="language-shell line-numbers"><span class="token comment"># &#x751F;&#x6210;&#x5BA2;&#x6237;&#x7AEF;&#x4EE3;&#x7801;: soapcpp2 -c -C xxx.h</span>
<span class="token comment"># xxx.h xxx.nsmap </span>
<span class="token comment"># soapC.c soapH.h soapStub.h </span>
<span class="token comment"># soapClient.c soapClientLib.c </span>
<span class="token comment"># xxx.add.req.xml xxx.add.res.xml xxx.sub.req.xml xxx.sub.res.xml</span>

<span class="token comment"># &#x751F;&#x6210;&#x670D;&#x52A1;&#x7AEF;&#x4EE3;&#x7801;: soapcpp2 -c -S xx.h</span>
<span class="token comment"># xxx.h xxx.nsmap </span>
<span class="token comment"># soapC.c soapH.h soapStub.h </span>
<span class="token comment"># soapServer.c soapServerLib.c </span>
<span class="token comment"># xxx.add.req.xml xxx.add.res.xml xxx.sub.req.xml xxx.sub.res.xml</span>

<span class="token comment"># &#x751F;&#x6210;&#x5BA2;&#x6237;&#x7AEF;&#x548C;&#x670D;&#x52A1;&#x7AEF;&#x4EE3;&#x7801;&#xFF0C;&#x4E3A;&#x672C;&#x6B21;&#x6267;&#x884C;&#x547D;&#x4EE4;</span>
$ soapcpp2 -c xxx.h
<span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></pre></li>
<li>&#x521B;&#x5EFA;&#x670D;&#x52A1;&#x7AEF;&#x4EE3;&#x7801;: <code>xxxserver.c</code><br>
&#x65B0;&#x589E;<code>ns2__add</code>&#x53CA;<code>ns2_sub</code>&#x63A5;&#x53E3;&#x7684;&#x5B9E;&#x73B0;&#xFF1A;<pre data-role="codeBlock" data-info="shell {.line-numbers}" class="language-shell line-numbers">int ns2__add<span class="token punctuation">(</span>struct soap *xxx_soap, int num1, int num2, int *sum<span class="token punctuation">)</span>
<span class="token punctuation">{</span>
    *sum <span class="token operator">=</span> num1 + num2<span class="token punctuation">;</span>
    <span class="token builtin class-name">return</span> <span class="token number">0</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
int ns2__sub<span class="token punctuation">(</span>struct soap *xxx_soap, int num1, int num2, int *sum<span class="token punctuation">)</span>
<span class="token punctuation">{</span>
    *sum <span class="token operator">=</span> num1 - num2<span class="token punctuation">;</span>
    <span class="token builtin class-name">return</span> <span class="token number">0</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>    
<span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></pre>&#x6574;&#x4F53;&#x4EE3;&#x7801;&#x5982;&#x4E0B;:<pre data-role="codeBlock" data-info="shell {.line-numbers}" class="language-shell line-numbers"><span class="token comment">#include &quot;soapH.h&quot;</span>
<span class="token comment">#include &quot;xxx.nsmap&quot;</span>

int main<span class="token punctuation">(</span>int argc, char **argv<span class="token punctuation">)</span>
<span class="token punctuation">{</span>
    int m, s<span class="token punctuation">;</span>
    struct soap xxx_soap<span class="token punctuation">;</span>
    soap_init<span class="token punctuation">(</span><span class="token operator">&amp;</span>xxx_soap<span class="token punctuation">)</span><span class="token punctuation">;</span>
    soap_set_namespaces<span class="token punctuation">(</span><span class="token operator">&amp;</span>xxx_soap, namespaces<span class="token punctuation">)</span><span class="token punctuation">;</span>

    <span class="token keyword keyword-if">if</span> <span class="token punctuation">(</span>argc <span class="token operator">&lt;</span> <span class="token number">2</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
        printf<span class="token punctuation">(</span><span class="token string">&quot;usage: %s &lt;server_port&gt; <span class="token entity" title="\n">\n</span>&quot;</span>, argv<span class="token punctuation">[</span><span class="token number">0</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        exit<span class="token punctuation">(</span><span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span> <span class="token keyword keyword-else">else</span> <span class="token punctuation">{</span>
        m <span class="token operator">=</span> soap_bind<span class="token punctuation">(</span><span class="token operator">&amp;</span>xxx_soap, NULL, atoi<span class="token punctuation">(</span>argv<span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">]</span><span class="token punctuation">)</span>, <span class="token number">100</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token keyword keyword-if">if</span> <span class="token punctuation">(</span>m <span class="token operator">&lt;</span> <span class="token number">0</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
            soap_print_fault<span class="token punctuation">(</span><span class="token operator">&amp;</span>xxx_soap, stderr<span class="token punctuation">)</span><span class="token punctuation">;</span>
            exit<span class="token punctuation">(</span>-1<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span>
        fprintf<span class="token punctuation">(</span>stderr, <span class="token string">&quot;[xxxserver]: Socket connection successful: master socket = %d<span class="token entity" title="\n">\n</span>&quot;</span>, m<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token keyword keyword-for">for</span> <span class="token punctuation">(</span><span class="token punctuation">;</span><span class="token punctuation">;</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
            s <span class="token operator">=</span> soap_accept<span class="token punctuation">(</span><span class="token operator">&amp;</span>xxx_soap<span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token keyword keyword-if">if</span> <span class="token punctuation">(</span>s <span class="token operator">&lt;</span> <span class="token number">0</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
                soap_print_fault<span class="token punctuation">(</span><span class="token operator">&amp;</span>xxx_soap, stderr<span class="token punctuation">)</span><span class="token punctuation">;</span>
                exit<span class="token punctuation">(</span>-1<span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token punctuation">}</span>
            fprintf<span class="token punctuation">(</span>stderr, <span class="token string">&quot;[xxxserver]: Socket connection successful: slave socket = %d<span class="token entity" title="\n">\n</span>&quot;</span>, s<span class="token punctuation">)</span><span class="token punctuation">;</span>
            soap_serve<span class="token punctuation">(</span><span class="token operator">&amp;</span>xxx_soap<span class="token punctuation">)</span><span class="token punctuation">;</span>
            soap_end<span class="token punctuation">(</span><span class="token operator">&amp;</span>xxx_soap<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span>
    <span class="token punctuation">}</span>
    <span class="token builtin class-name">return</span> <span class="token number">0</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
<span class="token comment">#if 1</span>
int ns2__add<span class="token punctuation">(</span>struct soap *xxx_soap, int num1, int num2, int *sum<span class="token punctuation">)</span>
<span class="token punctuation">{</span>
    *sum <span class="token operator">=</span> num1 + num2<span class="token punctuation">;</span>
    <span class="token builtin class-name">return</span> <span class="token number">0</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
int ns2__sub<span class="token punctuation">(</span>struct soap *xxx_soap, int num1, int num2, int *sum<span class="token punctuation">)</span>
<span class="token punctuation">{</span>
    *sum <span class="token operator">=</span> num1 - num2<span class="token punctuation">;</span>
    <span class="token builtin class-name">return</span> <span class="token number">0</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
<span class="token comment">#endif    </span>
<span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></pre></li>
<li>&#x521B;&#x5EFA;&#x5BA2;&#x6237;&#x7AEF;&#x4EE3;&#x7801;: <code>xxxclient.c</code><br>
&#x65B0;&#x589E;<code>add</code>&#x53CA;<code>sub</code>&#x63A5;&#x53E3;&#x7684;&#x5B9E;&#x73B0;&#xFF1A;<pre data-role="codeBlock" data-info="shell {.line-numbers}" class="language-shell line-numbers">int add<span class="token punctuation">(</span>const char *server, int num1, int num2, int *sum<span class="token punctuation">)</span>
<span class="token punctuation">{</span>
    struct soap xxx_soap<span class="token punctuation">;</span>
    <span class="token punctuation">..</span><span class="token punctuation">..</span><span class="token punctuation">..</span>
    soap_call_ns2__add<span class="token punctuation">(</span><span class="token operator">&amp;</span>xxx_soap, server, NULL, num1, num2, <span class="token function">sum</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">..</span><span class="token punctuation">..</span><span class="token punctuation">..</span>
    <span class="token builtin class-name">return</span> result<span class="token punctuation">;</span>
<span class="token punctuation">}</span>
int sub<span class="token punctuation">(</span>const char *server, int num1, int num2, int *sum<span class="token punctuation">)</span>
<span class="token punctuation">{</span>
    struct soap xxx_soap<span class="token punctuation">;</span>
    <span class="token punctuation">..</span><span class="token punctuation">..</span><span class="token punctuation">..</span>
    soap_call_ns2__sub<span class="token punctuation">(</span><span class="token operator">&amp;</span>xxx_soap, server, NULL, num1, num2, <span class="token function">sum</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">..</span><span class="token punctuation">..</span><span class="token punctuation">..</span>
    <span class="token builtin class-name">return</span> result<span class="token punctuation">;</span>
<span class="token punctuation">}</span>
<span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></pre>&#x6574;&#x4F53;&#x4EE3;&#x7801;&#x5982;&#x4E0B;:<pre data-role="codeBlock" data-info="shell {.line-numbers}" class="language-shell line-numbers"><span class="token comment">#include &quot;soapStub.h&quot;</span>
<span class="token comment">#include &quot;xxx.nsmap&quot;</span>

int add<span class="token punctuation">(</span>const char *server, int num1, int num2, int *sum<span class="token punctuation">)</span>
<span class="token punctuation">{</span>
    struct soap xxx_soap<span class="token punctuation">;</span>
    int result <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span>
    soap_init<span class="token punctuation">(</span><span class="token operator">&amp;</span>xxx_soap<span class="token punctuation">)</span><span class="token punctuation">;</span>
    soap_set_namespaces<span class="token punctuation">(</span><span class="token operator">&amp;</span>xxx_soap, namespaces<span class="token punctuation">)</span><span class="token punctuation">;</span>
    soap_call_ns2__add<span class="token punctuation">(</span><span class="token operator">&amp;</span>xxx_soap, server, NULL, num1, num2, <span class="token function">sum</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    printf<span class="token punctuation">(</span><span class="token string">&quot;[xxxclient]: server is %s, num1 is %d, num2 is %d<span class="token entity" title="\n">\n</span>&quot;</span>, server, num1, num2<span class="token punctuation">)</span><span class="token punctuation">;</span>

    <span class="token keyword keyword-if">if</span> <span class="token punctuation">(</span>xxx_soap.error<span class="token punctuation">)</span> <span class="token punctuation">{</span>
        printf<span class="token punctuation">(</span><span class="token string">&quot;[xxxclient]: soap error: %d, %s, %s<span class="token entity" title="\n">\n</span>&quot;</span>, xxx_soap.error, *soap_faultcode<span class="token punctuation">(</span><span class="token operator">&amp;</span>xxx_soap<span class="token punctuation">)</span>, *soap_faultstring<span class="token punctuation">(</span><span class="token operator">&amp;</span>xxx_soap<span class="token punctuation">))</span><span class="token punctuation">;</span>
        result <span class="token operator">=</span> xxx_soap.error<span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
    soap_end<span class="token punctuation">(</span><span class="token operator">&amp;</span>xxx_soap<span class="token punctuation">)</span><span class="token punctuation">;</span>
    soap_done<span class="token punctuation">(</span><span class="token operator">&amp;</span>xxx_soap<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token builtin class-name">return</span> result<span class="token punctuation">;</span>
<span class="token punctuation">}</span>

int sub<span class="token punctuation">(</span>const char *server, int num1, int num2, int *sum<span class="token punctuation">)</span>
<span class="token punctuation">{</span>
    struct soap xxx_soap<span class="token punctuation">;</span>
    int result <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span>
    soap_init<span class="token punctuation">(</span><span class="token operator">&amp;</span>xxx_soap<span class="token punctuation">)</span><span class="token punctuation">;</span>
    soap_set_namespaces<span class="token punctuation">(</span><span class="token operator">&amp;</span>xxx_soap, namespaces<span class="token punctuation">)</span><span class="token punctuation">;</span>
    soap_call_ns2__sub<span class="token punctuation">(</span><span class="token operator">&amp;</span>xxx_soap, server, NULL, num1, num2, <span class="token function">sum</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    printf<span class="token punctuation">(</span><span class="token string">&quot;[xxxclient]: server is %s, num1 is %d, num2 is %d<span class="token entity" title="\n">\n</span>&quot;</span>, server, num1, num2<span class="token punctuation">)</span><span class="token punctuation">;</span>

    <span class="token keyword keyword-if">if</span> <span class="token punctuation">(</span>xxx_soap.error<span class="token punctuation">)</span> <span class="token punctuation">{</span>
        printf<span class="token punctuation">(</span><span class="token string">&quot;[xxxclient]: soap error: %d, %s, %s<span class="token entity" title="\n">\n</span>&quot;</span>, xxx_soap.error, *soap_faultcode<span class="token punctuation">(</span><span class="token operator">&amp;</span>xxx_soap<span class="token punctuation">)</span>, *soap_faultstring<span class="token punctuation">(</span><span class="token operator">&amp;</span>xxx_soap<span class="token punctuation">))</span><span class="token punctuation">;</span>
        result <span class="token operator">=</span> xxx_soap.error<span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
    soap_end<span class="token punctuation">(</span><span class="token operator">&amp;</span>xxx_soap<span class="token punctuation">)</span><span class="token punctuation">;</span>
    soap_done<span class="token punctuation">(</span><span class="token operator">&amp;</span>xxx_soap<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token builtin class-name">return</span> result<span class="token punctuation">;</span>
<span class="token punctuation">}</span>    
<span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></pre></li>
<li>&#x521B;&#x5EFA;&#x6D4B;&#x8BD5;&#x4EE3;&#x7801;: <code>xxxtest.c</code><br>
&#x5F15;&#x7528;<code>add</code>&#x53CA;<code>sub</code>&#x63A5;&#x53E3;:<pre data-role="codeBlock" data-info="shell {.line-numbers}" class="language-shell line-numbers">int add<span class="token punctuation">(</span>const char *server, int num1, int num2, int *sum<span class="token punctuation">)</span><span class="token punctuation">;</span>
int sub<span class="token punctuation">(</span>const char *server, int num1, int num2, int *sum<span class="token punctuation">)</span><span class="token punctuation">;</span>    
<span aria-hidden="true" class="line-numbers-rows"><span></span><span></span></span></pre>&#x6574;&#x4F53;&#x4EE3;&#x7801;&#x5982;&#x4E0B;:<pre data-role="codeBlock" data-info="shell {.line-numbers}" class="language-shell line-numbers"><span class="token comment">#include &lt;stdio.h&gt;</span>
<span class="token comment">#include &lt;stdlib.h&gt;</span>
<span class="token comment">#include &lt;string.h&gt;</span>

int add<span class="token punctuation">(</span>const char *server, int num1, int num2, int *sum<span class="token punctuation">)</span><span class="token punctuation">;</span>
int sub<span class="token punctuation">(</span>const char *server, int num1, int num2, int *sum<span class="token punctuation">)</span><span class="token punctuation">;</span>
int main<span class="token punctuation">(</span>int argc, char **argv<span class="token punctuation">)</span>
<span class="token punctuation">{</span>
    int result <span class="token operator">=</span> -1<span class="token punctuation">;</span>
    char server<span class="token punctuation">[</span><span class="token number">128</span><span class="token punctuation">]</span> <span class="token operator">=</span> <span class="token punctuation">{</span><span class="token number">0</span><span class="token punctuation">}</span><span class="token punctuation">;</span>
    int num1<span class="token punctuation">;</span>
    int num2<span class="token punctuation">;</span>
    int <span class="token function">sum</span><span class="token punctuation">;</span>

    <span class="token keyword keyword-if">if</span> <span class="token punctuation">(</span>argc <span class="token operator">&lt;</span> <span class="token number">4</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
        printf<span class="token punctuation">(</span><span class="token string">&quot;usage: %s &lt;ip:port&gt; num1 num2 <span class="token entity" title="\n">\n</span>&quot;</span>, argv<span class="token punctuation">[</span><span class="token number">0</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        exit<span class="token punctuation">(</span><span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>

    strcpy<span class="token punctuation">(</span>server,argv<span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    num1 <span class="token operator">=</span> atoi<span class="token punctuation">(</span>argv<span class="token punctuation">[</span><span class="token number">2</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    num2 <span class="token operator">=</span> atoi<span class="token punctuation">(</span>argv<span class="token punctuation">[</span><span class="token number">3</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

        //
    result <span class="token operator">=</span> add<span class="token punctuation">(</span>server, num1, num2,<span class="token operator">&amp;</span><span class="token function">sum</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token keyword keyword-if">if</span> <span class="token punctuation">(</span>result <span class="token operator">!=</span> <span class="token number">0</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
        printf<span class="token punctuation">(</span><span class="token string">&quot;[xxxtest]: soap error, errcode=%d<span class="token entity" title="\n">\n</span>&quot;</span>, result<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span> <span class="token keyword keyword-else">else</span> <span class="token punctuation">{</span>
        printf<span class="token punctuation">(</span><span class="token string">&quot;[xxxtest]: %d + %d = %d<span class="token entity" title="\n">\n</span>&quot;</span>, num1, num2, <span class="token function">sum</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>

        //
    result <span class="token operator">=</span> sub<span class="token punctuation">(</span>server, num1, num2,<span class="token operator">&amp;</span><span class="token function">sum</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token keyword keyword-if">if</span> <span class="token punctuation">(</span>result <span class="token operator">!=</span> <span class="token number">0</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
        printf<span class="token punctuation">(</span><span class="token string">&quot;[xxxtest]: soap error, errcode=%d<span class="token entity" title="\n">\n</span>&quot;</span>, result<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span> <span class="token keyword keyword-else">else</span> <span class="token punctuation">{</span>
        printf<span class="token punctuation">(</span><span class="token string">&quot;[xxxtest]: %d - %d = %d<span class="token entity" title="\n">\n</span>&quot;</span>, num1, num2, <span class="token function">sum</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>

    <span class="token builtin class-name">return</span> <span class="token number">0</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>    
<span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></pre></li>
<li>&#x7F16;&#x5199;Makefile<br>
&#x7F16;&#x8BD1;&#x524D;&#xFF0C;&#x5148;&#x5C06;gsoap-2.8\gsoap&#x76EE;&#x5F55;&#x4E0B;&#x7684;stdsoap2.c&#x548C;stdsoap2.h&#x590D;&#x5236;&#x5230;&#x5F53;&#x524D;&#x76EE;&#x5F55;&#x4E0B;&#x3002;<pre data-role="codeBlock" data-info="shell {.line-numbers}" class="language-shell line-numbers">GSOAP_ROOT <span class="token operator">=</span> <span class="token punctuation">..</span>/gsoap-2.8/gsoap
CC <span class="token operator">=</span> gcc -g -DWITH_NONAMESPACES
INCLUDE <span class="token operator">=</span> -I<span class="token variable"><span class="token variable">$(</span>GSOAP_ROOT<span class="token variable">)</span></span>
SERVER_OBJS <span class="token operator">=</span> soapC.o stdsoap2.o soapServer.o xxxserver.o 
CLIENT_OBJS <span class="token operator">=</span> soapC.o stdsoap2.o soapClient.o xxxclient.o xxxtest.o

all: server
server: <span class="token variable"><span class="token variable">$(</span>SERVER_OBJS<span class="token variable">)</span></span> 
        <span class="token variable"><span class="token variable">$(</span>CC<span class="token variable">)</span></span> <span class="token variable"><span class="token variable">$(</span>INCLUDE<span class="token variable">)</span></span> -o xxxserver <span class="token variable"><span class="token variable">$(</span>SERVER_OBJS<span class="token variable">)</span></span> 

client: <span class="token variable"><span class="token variable">$(</span>CLIENT_OBJS<span class="token variable">)</span></span> 
        <span class="token variable"><span class="token variable">$(</span>CC<span class="token variable">)</span></span> <span class="token variable"><span class="token variable">$(</span>INCLUDE<span class="token variable">)</span></span> -o xxxtest <span class="token variable"><span class="token variable">$(</span>CLIENT_OBJS<span class="token variable">)</span></span>

clean:
        <span class="token function">rm</span> -f *.o xxxtest    
<span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></pre></li>
<li>&#x7F16;&#x8BD1;&#x7A0B;&#x5E8F;<pre data-role="codeBlock" data-info="shell {.line-numbers}" class="language-shell line-numbers"><span class="token comment"># &#x7F16;&#x8BD1;&#x5BA2;&#x6237;&#x7AEF;</span>
$ <span class="token function">make</span> client
<span class="token comment"># &#x7F16;&#x8BD1;&#x670D;&#x52A1;&#x7AEF;</span>
$ <span class="token function">make</span> server
<span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span></span></pre></li>
<li>&#x6D4B;&#x8BD5;&#x7A0B;&#x5E8F;<pre data-role="codeBlock" data-info="shell {.line-numbers}" class="language-shell line-numbers"><span class="token comment"># &#x8FD0;&#x884C;&#x670D;&#x52A1;&#x7AEF;</span>
$ ./xxxserver <span class="token number">12345</span>
<span class="token punctuation">[</span>xxxserver<span class="token punctuation">]</span>: Socket connection successful: master socket <span class="token operator">=</span> <span class="token number">3</span>

<span class="token comment"># &#x8FD0;&#x884C;&#x5BA2;&#x6237;&#x7AEF;</span>
$ ./xxxtest <span class="token number">127.0</span>.0.1:12345 <span class="token number">1</span> <span class="token number">2</span>
<span class="token punctuation">[</span>xxxclient<span class="token punctuation">]</span>: server is <span class="token number">127.0</span>.0.1:12345, num1 is <span class="token number">1</span>, num2 is <span class="token number">2</span>
<span class="token punctuation">[</span>xxxtest<span class="token punctuation">]</span>: <span class="token number">1</span> + <span class="token number">2</span> <span class="token operator">=</span> <span class="token number">3</span>
<span class="token punctuation">[</span>xxxclient<span class="token punctuation">]</span>: server is <span class="token number">127.0</span>.0.1:12345, num1 is <span class="token number">1</span>, num2 is <span class="token number">2</span>
<span class="token punctuation">[</span>xxxtest<span class="token punctuation">]</span>: <span class="token number">1</span> - <span class="token number">2</span> <span class="token operator">=</span> -1    
<span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></pre></li>
</ol>
<h2 class="mume-header undefined" id="H-4">4. FAQ</h2>

<h3 class="mume-header undefined" id="H-4-1">4.1 FAQ1</h3>

<ol>
<li>
<p>WARNING: &apos;automake-1.16&apos; is missing on your system.<br>
A: wget <a href="https://ftp.gnu.org/gnu/automake/automake-1.16.tar.gz">https://ftp.gnu.org/gnu/automake/automake-1.16.tar.gz</a><br>
2018-02-25 16:24	2.2M	<br>
configure: error: Autoconf 2.65 or better is required.</p>
<ul>
<li>&#x5B89;&#x88C5;autoconf<pre data-role="codeBlock" data-info="shell {.line-numbers}" class="language-shell line-numbers"><span class="token comment"># 2012-04-24 23:17	1.8M</span>
$ <span class="token function">wget</span> https://ftp.gnu.org/gnu/autoconf/autoconf-2.69.tar.gz
<span aria-hidden="true" class="line-numbers-rows"><span></span><span></span></span></pre></li>
</ul>
</li>
<li>
<p>WARNING: &apos;aclocal-1.16&apos; is missing on your system.<br>
A:</p>
</li>
<li>
<p>&#x7F16;&#x8BD1;automake&#x65F6;&#x63D0;&#x793A;</p>
<pre data-role="codeBlock" data-info="shell {.line-numbers}" class="language-shell line-numbers">elp2man: can<span class="token string">&apos;t get `--help&apos;</span> info from automake-1.16
Try `--no-discard-stderr&apos; <span class="token keyword keyword-if">if</span> option outputs to stderr
make: *** <span class="token punctuation">[</span>doc/automake-1.16.1<span class="token punctuation">]</span> &#x9519;&#x8BEF; <span class="token number">255</span>
<span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span></span></pre><p>A:</p>
<pre data-role="codeBlock" data-info="shell {.line-numbers}" class="language-shell line-numbers"><span class="token comment"># &#x5728;Makefile 3694&#x884C; &#x672B;&#x5C3E;&#x52A0;&#x4E0A;--no-discard-stderr</span>
$ <span class="token function">vi</span> Makefile +3694
doc/aclocal-<span class="token variable"><span class="token variable">$(</span>APIVERSION<span class="token variable">)</span></span>.1: <span class="token variable"><span class="token variable">$(</span>aclocal_script<span class="token variable">)</span></span> lib/Automake/Config.pm
            <span class="token variable"><span class="token variable">$(</span>update_mans<span class="token variable">)</span></span> aclocal-<span class="token variable"><span class="token variable">$(</span>APIVERSION<span class="token variable">)</span></span>
    doc/automake-<span class="token variable"><span class="token variable">$(</span>APIVERSION<span class="token variable">)</span></span>.1: <span class="token variable"><span class="token variable">$(</span>automake_script<span class="token variable">)</span></span> lib/Automake/Config.pm
            <span class="token variable"><span class="token variable">$(</span>update_mans<span class="token variable">)</span></span> automake-<span class="token variable"><span class="token variable">$(</span>APIVERSION<span class="token variable">)</span></span> --no-discard-stderr
<span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span></span></pre></li>
<li>
<p>&#x5B89;&#x88C5;<code>autoconf</code>&#x53CA;<code>automake</code>&#x540E;&#xFF0C;make gsoap&#x65F6;&#x63D0;&#x793A;&#xFF1A;</p>
<pre data-role="codeBlock" data-info="shell {.line-numbers}" class="language-shell line-numbers">WARNING: <span class="token string">&apos;automake-1.16&apos;</span> is probably too old.
         You should only need it <span class="token keyword keyword-if">if</span> you modified <span class="token string">&apos;Makefile.am&apos;</span> or
         <span class="token string">&apos;configure.ac&apos;</span> or m4 files included by <span class="token string">&apos;configure.ac&apos;</span><span class="token builtin class-name">.</span>
         The <span class="token string">&apos;automake&apos;</span> program is part of the GNU Automake package:
         <span class="token operator">&lt;</span>https://www.gnu.org/software/automake<span class="token operator">&gt;</span>
         It also requires GNU Autoconf, GNU m4 and Perl <span class="token keyword keyword-in">in</span> order to run:
         <span class="token operator">&lt;</span>https://www.gnu.org/software/autoconf<span class="token operator">&gt;</span>
         <span class="token operator">&lt;</span>https://www.gnu.org/software/m4/<span class="token operator">&gt;</span>
         <span class="token operator">&lt;</span>https://www.perl.org/<span class="token operator">&gt;</span>
make: *** <span class="token punctuation">[</span>Makefile.in<span class="token punctuation">]</span> Error <span class="token number">1</span>    
<span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></pre><p>A:</p>
<pre data-role="codeBlock" data-info="shell {.line-numbers}" class="language-shell line-numbers">$ aclocal
$ automake -a -c
$ <span class="token function">make</span>
<span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span></span></pre><p>&#x63D0;&#x793A;:</p>
<ol>
<li>aclocal<br>
&#x6839;&#x636E;configure.in&#x7684;&#x5185;&#x5BB9;&#xFF08;&#x4E3B;&#x8981;&#x662F;&#x5176;&#x4E2D;&#x7528;&#x5230;&#x7684;m4&#x5B8F;&#xFF09;&#x5230;&#x6307;&#x5B9A;&#x7684;&#x8DEF;&#x5F84;&#x4E0B;&#x7684;m4&#x5B8F;&#x5B9A;&#x4E49;&#x6587;&#x4EF6;&#x4E2D;&#x63D0;&#x53D6;&#x7528;&#x5230;&#x7684;&#x5B8F;&#x5B9A;&#x4E49;&#xFF0C;&#x5199;&#x5230;aclocal.m4&#x6587;&#x4EF6;&#x4E2D;&#xFF0C;&#x4F9B;automake&#x4F7F;&#x7528;</li>
</ol>
</li>
<li>
<p>gsoap:</p>
<pre data-role="codeBlock" data-info="shell {.line-numbers}" class="language-shell line-numbers">soapStub.h:15:3: error: <span class="token comment">#error &quot;GSOAP VERSION MISMATCH IN GENERATED CODE: PLEASE REINSTALL PACKAGE&quot;</span>
 <span class="token comment"># error &quot;GSOAP VERSION MISMATCH IN GENERATED CODE: PLEASE REINSTALL PACKAGE&quot;    </span>
<span aria-hidden="true" class="line-numbers-rows"><span></span><span></span></span></pre><p>A: gsoap&#x5DE5;&#x5177;&#x8DDF;stdsoap2.c&#x53CA;stdsoap2.h&#x6587;&#x4EF6;&#x7248;&#x672C;&#x4E0D;&#x4E00;&#x81F4;&#x5BFC;&#x81F4;&#x7684;&#xFF0C;&#x4F7F;&#x7528;&#x7EDF;&#x4E00;&#x7248;&#x672C;&#x5B8C;&#x7F8E;&#x89E3;&#x51B3;</p>
</li>
<li>
<p>&#x8C03;&#x8BD5;&#x5BA2;&#x6237;&#x7AEF;&#x65F6;&#x63D0;&#x793A;:</p>
<pre data-role="codeBlock" data-info="shell {.line-numbers}" class="language-shell line-numbers">gsoap HTTP GET method not implemented
<span aria-hidden="true" class="line-numbers-rows"><span></span></span></pre><p>A: &#x670D;&#x52A1;&#x7AEF;&#x6CA1;&#x6709;&#x5B9E;&#x73B0;HTTP GET&#x63A5;&#x53E3;&#xFF0C;&#x67E5;&#x770B;&#x670D;&#x52A1;&#x7AEF;<code>xxxServer.c</code>&#x6E90;&#x4EE3;&#x7801;&#xFF0C;&#x6DFB;&#x52A0;HTTP GET&#x7684;&#x5904;&#x7406;&#x51FD;&#x6570;&#x540E;&#xFF0C;&#x91CD;&#x65B0;&#x7F16;&#x8BD1;&#x3002;</p>
</li>
<li>
<p>GSOAP&#x7B2C;3&#x65B9;&#x7F16;&#x8BD1;<br>
A: &#x9700;&#x8981;&#x62F7;&#x8D1D;stdsoap2.h&#x3001;stdsoap2.cpp&#xFF0C; &#x5728;&#x4EE3;&#x7801;&#x91CC;&#x5305;&#x542B; *.nsmap&#x6587;&#x4EF6;<br>
&#x5982;&#x679C;&#x6709;&#x4E9B;&#x5916;&#x90E8;&#x7B26;&#x53F7;&#x65E0;&#x6CD5;&#x89E3;&#x6790;&#xFF0C; &#x6BD4;&#x5982;soap_in_xsd__duration&#x4E4B;&#x7C7B;&#x7684;&#xFF0C; &#x9700;&#x8981;&#x62F7;&#x8D1D;duration.h&#x3001;duration.c&#xFF08;gsoap\custom&#x76EE;&#x5F55;&#x4E0B;&#xFF09;&#xFF0C;<br>
&#x5982;&#x679C;&#x662F;C++&#x5DE5;&#x7A0B;&#xFF0C; duration.c&#x91CD;&#x547D;&#x540D;&#x4E3A;duration.cpp</p>
</li>
</ol>
<h3 class="mume-header undefined" id="H-4-2">4.2 &#x793A;&#x4F8B;&#x6F14;&#x793A;FAQ</h3>

<ol>
<li>&#x7F16;&#x8BD1;&#x62A5;&#x9519;<pre data-role="codeBlock" data-info="shell {.line-numbers}" class="language-shell line-numbers">undefined reference to <span class="token variable"><span class="token variable">`</span>ns2__add<span class="token punctuation">(</span>soap*, double, double, double*<span class="token punctuation">)</span>&apos; soapServer.o: In <span class="token keyword keyword-function">function</span> <span class="token variable">`</span></span>soap_serve_ns2__sub<span class="token punctuation">(</span>soap*<span class="token punctuation">)</span><span class="token string">&apos;:
undefined reference to `ns2__sub(soap*, double, double, double*)&apos;</span> soapServer.o: In <span class="token keyword keyword-function">function</span> `soap_serve_ns2__mul<span class="token punctuation">(</span>soap*<span class="token punctuation">)</span>&apos;:
<span class="token punctuation">..</span><span class="token punctuation">..</span><span class="token punctuation">..</span>
<span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span></span></pre>A: &#x6709;&#x53EF;&#x80FD;&#x662F;&#x4E0B;&#x9762;&#x7684;&#x539F;&#x56E0;:
<ol>
<li>calc.h&#x4E2D;&#x6709;&#x5BF9;ns2_sub&#x63A5;&#x53E3;&#x7684;&#x58F0;&#x660E;&#xFF0C;&#x8BF4;&#x660E;&#x8981;&#x4F7F;&#x7528;&#x8BE5;&#x63A5;&#x53E3;</li>
<li>&#x4F46;&#x5728;test_server.c&#x672A;&#x6709;&#x5BF9;&#x4E0A;&#x8FF0;&#x63A5;&#x53E3;&#x8FDB;&#x884C;&#x5B9A;&#x4E49;&#x5B9E;&#x73B0;&#xFF0C;</li>
<li>&#x7F16;&#x8BD1;&#x8FC7;&#x7A0B;&#x4E2D;&#xFF0C;&#x9047;&#x5230;&#x6CA1;&#x6709;&#x5B9E;&#x73B0;&#x7684;&#x51FD;&#x6570;&#x63A5;&#x53E3;&#x65F6;&#xFF0C;&#x4F1A;&#x63D0;&#x793A;&#x4E0A;&#x9762;&#x7684;&#x9519;&#x8BEF;&#x4FE1;&#x606F;&#x3002;</li>
</ol>
</li>
</ol>
<h2 class="mume-header undefined" id="H-5">5. &#x9644;&#x5F55;</h2>

<h3 class="mume-header undefined" id="H-5-1">5.1 gsoap&#x901A;&#x7528;&#x6587;&#x4EF6;</h3>

<ul>
<li>&#x6587;&#x4EF6;&#x5217;&#x8868;
<ul>
<li>.xsd<br>
&#x4F20;&#x8F93;&#x6D88;&#x606F;&#x7684;schema&#xFF0C;&#xFF0C;&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x770B;&#x770B;&#x662F;&#x5426;&#x6EE1;&#x8DB3;&#x6211;&#x4EEC;&#x7684;&#x534F;&#x8BAE;&#x683C;&#x5F0F;&#xFF08;&#x5982;&#x679C;&#x6709;&#x6B64;&#x8981;&#x6C42;&#xFF09;</li>
<li>.nsmap<br>
&#x547D;&#x540D;&#x7A7A;&#x95F4;&#x7684;&#x5B9A;&#x4E49;&#xFF0C;&#x5BF9;&#x547D;&#x540D;&#x7A7A;&#x95F4;&#x4E0D;&#x654F;&#x611F;&#x7684;&#xFF0C;&#x4E0D;&#x7528;&#x5173;&#x6CE8;&#x3002;</li>
<li>typemap.dat<br>
wsdl2h&#x5DE5;&#x5177;&#x6839;&#x636E;wsdl&#x6587;&#x4EF6;&#x751F;&#x6210;&#x5934;&#x6587;&#x4EF6;&#x65F6;&#x9700;&#x8981;&#x6B64;&#x6587;&#x4EF6;&#xFF0C;&#x53EF;&#x4EE5;&#x66F4;&#x6539;&#x9879;&#x76EE;&#x7684;xml&#x547D;&#x540D;&#x7A7A;&#x95F4;<br>
type map&#x6587;&#x4EF6;&#x7528;&#x4E8E;&#x6307;&#x5B9A;SOAP/XML&#x4E2D;&#x7684;&#x7C7B;&#x578B;&#x4E0E;C/C++&#x4E4B;&#x95F4;&#x7684;&#x8F6C;&#x6362;&#x89C4;&#x5219;&#xFF0C;&#x6BD4;&#x5982;&#x5728;wsmap.dat&#x91CC;&#x5199;<pre data-role="codeBlock" data-info="shell {.line-numbers}" class="language-shell line-numbers">xsd__string <span class="token operator">=</span> <span class="token operator">|</span> std::wstring <span class="token operator">|</span> wchar_t*
<span aria-hidden="true" class="line-numbers-rows"><span></span></span></pre>&#x90A3;&#x4E48;SOAP/XML&#x4E2D;&#x7684;string&#x5C06;&#x8F6C;&#x6362;&#x6210;std::wstring&#x6216;wchar_t*&#xFF0C;&#x8FD9;&#x6837;&#x80FD;&#x66F4;&#x597D;&#x5730;&#x652F;&#x6301;&#x4E2D;&#x6587;&#x3002;<br>
&#x4F8B;:<pre data-role="codeBlock" data-info="shell {.line-numbers}" class="language-shell line-numbers">$ wsdl2h -o ayandy.h -n ay -t wsmap.dat http://www.ayandy.com/Service.asmx?WSDL
<span aria-hidden="true" class="line-numbers-rows"><span></span></span></pre>&#x5373;: &#x4ECE;http://www.ayandy.com/Service.asmx?WSDL &#x751F;&#x6210;ayandy.h&#x6587;&#x4EF6;&#xFF0C;&#x540D;&#x7A7A;&#x95F4;&#x4E3A;ay&#xFF0C;&#x4F7F;&#x7528;wsmap.dat&#x6307;&#x5B9A;&#x7684;&#x8F6C;&#x6362;&#x89C4;&#x5219;&#x3002;</li>
<li>threads.h&#xFF1A;<br>
&#x5B9E;&#x73B0;&#x9AD8;&#x6027;&#x80FD;&#x7684;&#x591A;&#x7EBF;&#x7A0B;&#x670D;&#x52A1;&#x5668;&#x9700;&#x8981;&#x7684;&#x6587;&#x4EF6;&#xFF0C;&#x53EF;&#x4EE5;&#x5E76;&#x53D1;&#x5904;&#x7406;&#x8BF7;&#x6C42;&#xFF0C;&#x5E76;&#x4E14;&#x5728;&#x670D;&#x52A1;&#x64CD;&#x4F5C;&#x53D8;&#x5F97;&#x8017;&#x65F6;&#x65F6;&#x4E0D;&#x4F1A;&#x963B;&#x585E;&#x5176;&#x4ED6;&#x5BA2;&#x6237;&#x7AEF;&#x8BF7;&#x6C42;</li>
<li><strong>stdsoap2.h&#x3001;stdsoap2.cpp</strong><br>
HTTP&#x534F;&#x8BAE;&#x7684;&#x5B9E;&#x73B0;&#x3001;&#x6700;&#x7EC8;&#x7684;SOAP&#x62A5;&#x6587;&#x751F;&#x6210;&#xFF0C;&#x5982;&#x679C;&#x662F;C&#x8BED;&#x8A00;&#x5219;&#x4F7F;&#x7528;stdsoap2.h&#x3001;stdsoap2.c</li>
<li><strong>soapStub.h</strong><br>
soap&#x7684;&#x5B58;&#x6839;&#x6587;&#x4EF6;&#xFF0C;&#x5B9A;&#x4E49;&#x4E86;ayandy.h&#x91CC;&#x5BF9;&#x5E94;&#x7684;&#x8FDC;&#x7A0B;&#x8C03;&#x7528;&#x6A21;&#x578B;<br>
&#x6839;&#x636E;&#x8F93;&#x5165;&#x7684;.h&#x6587;&#x4EF6;&#x751F;&#x6210;&#x7684;&#x6570;&#x636E;&#x5B9A;&#x4E49;&#x6587;&#x4EF6;&#xFF0C;&#x4E00;&#x822C;&#x6211;&#x4EEC;&#x4E0D;&#x76F4;&#x63A5;&#x5F15;&#x7528;&#x5B83;&#x3002;<br>
&#x672C;&#x6587;&#x4EF6;&#x4F1A;&#x4F9D;&#x8D56;&#xFF1A;&quot;stdsoap2.h&quot;</li>
<li><strong>soapC.c soapH.h</strong><br>
soap&#x7684;&#x5E8F;&#x5217;&#x548C;&#x53CD;&#x5E8F;&#x5217;&#x4EE3;&#x7801;&#xFF0C;&#x5B83;&#x5DF2;&#x7ECF;&#x5305;&#x542B;&#x4E86;soapStub.h&#xFF0C; <strong>&#x670D;&#x52A1;&#x5668;&#x7AEF;&#x4E0E;&#x5BA2;&#x6237;&#x7AEF;&#x90FD;&#x8981;&#x5305;&#x542B;&#x5B83;</strong><br>
&#x6587;&#x4EF6;&#x5305;&#x542B;&#xFF1A; <code>#include &quot;soapStub.h&quot;</code></li>
<li><strong>ServiceSoap.nsmap ServiceSoap12.nsmap</strong><br>
&#x540D;&#x7A7A;&#x95F4;&#x5B9A;&#x4E49;&#xFF0C;<strong>&#x670D;&#x52A1;&#x5668;&#x7AEF;&#x4E0E;&#x5BA2;&#x6237;&#x7AEF;&#x90FD;&#x8981;&#x5305;&#x542B;&#x5B83;</strong></li>
<li>soapXXXProxy.h soapXXXProxy.h<br>
&#x5BA2;&#x6237;&#x7AEF;&#x7684;C++&#x7B80;&#x5355;&#x5305;&#x88C5;(&#x5982;&#x679C;&#x5934;&#x6587;&#x4EF6;&#x662F;&#x7EAF;C&#x4EE3;&#x7801;&#xFF0C;&#x8FD9;&#x4E24;&#x4E2A;&#x6587;&#x4EF6;&#x5C31;&#x4E0D;&#x4F1A;&#x751F;&#x6210;)<br>
&#x8FD9;&#x4E24;&#x4E2A;&#x6587;&#x4EF6;&#x7528;&#x4E8E;&#x5BA2;&#x6237;&#x7AEF;&#xFF0C;&#x662F;&#x5BA2;&#x6237;&#x7AEF;&#x8C03;&#x7528;webservice&#x7684;&#x6846;&#x67B6;&#x6587;&#x4EF6;&#xFF0C;&#x6211;&#x4EEC;&#x7684;&#x4EE3;&#x7801;&#x4E3B;&#x8981;&#x5728;&#x6B64;&#x5B9E;&#x73B0;&#x6216;&#x4ECE;&#x5B83;&#x7EE7;&#x627F;&#x3002;</li>
<li>soapXXXService.h soapXXXService.h<br>
&#x8FD9;&#x4E24;&#x4E2A;&#x6587;&#x4EF6;&#x7528;&#x4E8E;&#x670D;&#x52A1;&#x5668;&#x7AEF;&#xFF0C;&#x662F;&#x670D;&#x52A1;&#x5668;&#x7AEF;&#x5B9E;&#x73B0;webservice&#x7684;&#x6846;&#x67B6;&#x6587;&#x4EF6;&#xFF0C;&#x6211;&#x4EEC;&#x7684;&#x4EE3;&#x7801;&#x4E3B;&#x8981;&#x5728;&#x6B64;&#x5B9E;&#x73B0;&#x6216;&#x4ECE;&#x5B83;&#x7EE7;&#x627F;&#x3002;</li>
<li><strong>soapClient.c</strong> soapClientLib.c<br>
&#x5BA2;&#x6237;&#x7AEF;&#x4EE3;&#x7801;&#xFF0C;soapClientLib.c&#x6587;&#x4EF6;&#x5219;&#x53EA;&#x662F;&#x7B80;&#x5355;&#x5730;&#x5305;&#x542B;soapClient.c&#x548C;soapC.c</li>
<li><strong>soapServer.c</strong> soapServerLib.c<br>
&#x670D;&#x52A1;&#x5668;&#x7AEF;&#x4EE3;&#x7801;,soapServerLib.c&#x6587;&#x4EF6;&#x5219;&#x53EA;&#x662F;&#x7B80;&#x5355;&#x5730;&#x5305;&#x542B;soapServer.c&#x548C;soapC.c</li>
</ul>
</li>
<li>&#x603B;&#x7ED3;
<ul>
<li>&#x4F9D;&#x8D56;&#x5173;&#x7CFB;<br>
soapC.c --&gt; soapH.h --&gt; soapStub.h --&gt; stdsoap2.h(.cpp)<br>
soapServer.c(soapClient.c) --&gt; soapH.h<br>
soapServerLib.c --&gt; soapServer.c, soapC.c<br>
soapClientLib.c --&gt; soapClient.c, soapC.c</li>
<li>&#x5982;&#x679C;&#x7F16;&#x5199;&#x670D;&#x52A1;&#x5668;&#x7AEF;&#xFF0C;&#x9879;&#x76EE;&#x91CC;&#x5E94;&#x8BE5;&#x52A0;&#x5165;soapServerLib.c&#xFF0C;&#x4EE3;&#x7801;&#x91CC;&#x5305;&#x542B;&#x5934;&#x6587;&#x4EF6;soapH.h</li>
<li>&#x5982;&#x679C;&#x7F16;&#x5199;&#x5BA2;&#x6237;&#x7AEF;&#xFF0C;&#x9879;&#x76EE;&#x91CC;&#x5E94;&#x8BE5;&#x52A0;&#x5165;soapClientLib.c&#xFF0C;&#x4EE3;&#x7801;&#x91CC;&#x5305;&#x542B;&#x5934;&#x6587;&#x4EF6;SoapH.h&#xFF08;&#x6216;xxxxProxy.h&#xFF09;</li>
<li>&#x5F53;&#x7136;&#xFF0C;&#x8FD8;&#x8981;&#x52A0;&#x5165;gsoap&#x5E93;&#x91CC;&#x7684;stdsoap2.cpp&#x6587;&#x4EF6;&#xFF08;&#x5982;&#x679C;&#x662F;&#x5199;C&#x4EE3;&#x7801;&#xFF0C;&#x5219;&#x52A0;&#x5165;stdsoap2.c&#xFF09;</li>
</ul>
</li>
</ul>
<h3 class="mume-header undefined" id="H-5-2">5.2 wsdl&#x547D;&#x4EE4;</h3>

<p>&#x636E;&#x8BF4;&#xFF0C;typemap.dat&#xFF08;gsoap&#x76EE;&#x5F55;&#x4E0B;&#xFF09;&#x6700;&#x597D;&#x62F7;&#x8D1D;&#x5230;&#x540C;&#x4E00;&#x76EE;&#x5F55;&#x4E0B;&#x3002;</p>
<ul>
<li>wsdl<br>
<strong>-c</strong> &#x4EA7;&#x751F;&#x7EAF;C&#x4EE3;&#x7801;&#xFF0C;&#x5426;&#x5219;&#x662F;C++&#x4EE3;&#x7801;<br>
-e &#x7981;&#x6B62;&#x4E3A;enum&#x6210;&#x5458;&#x52A0;&#x4E0A;&#x540D;&#x7A7A;&#x95F4;&#x524D;&#x7F00;<br>
<strong>-n xx</strong> &#x540D;&#x7A7A;&#x95F4;&#x524D;&#x7F00;, &#x4F7F;&#x7528;name&#x4EE3;&#x66FF;&#x9ED8;&#x8BA4;&#x524D;&#x7F00;ns.<br>
<strong>-o</strong> &#x6587;&#x4EF6;&#x540D;&#xFF0C;&#x6307;&#x5B9A;&#x8F93;&#x51FA;&#x5934;&#x6587;&#x4EF6;<br>
<strong>-s</strong> &#x4E0D;&#x8981;&#x4F7F;&#x7528;STL&#x4EE3;&#x7801;<br>
-t <code>&lt;filename.dat&gt;</code> &#x4F7F;&#x7528;filename.dat&#x4EE3;&#x66FF;&#x9ED8;&#x8BA4;&#x7684;typemap.dat&#x6587;&#x4EF6;<br>
-zX &#x517C;&#x5BB9;&#x4E4B;&#x524D;&#x7684;X&#x7248;&#x672C;</li>
<li>&#x793A;&#x4F8B;<pre data-role="codeBlock" data-info="shell {.line-numbers}" class="language-shell line-numbers">$ wsdl2h -sc -t typemap.dat -o xxx.h x1.wsdl <span class="token punctuation">[</span>x2.wsdl x3.wsdl <span class="token punctuation">..</span><span class="token punctuation">..</span><span class="token punctuation">..</span><span class="token punctuation">]</span> 
<span aria-hidden="true" class="line-numbers-rows"><span></span></span></pre></li>
<li>&#x5907;&#x6CE8;</li>
</ul>
<h3 class="mume-header undefined" id="H-5-3">5.3 soapcpp2</h3>

<p>&#x636E;&#x8BF4;&#xFF0C;typemap.dat&#xFF08;gsoap&#x76EE;&#x5F55;&#x4E0B;&#xFF09;&#x6700;&#x597D;&#x62F7;&#x8D1D;&#x5230;&#x540C;&#x4E00;&#x76EE;&#x5F55;&#x4E0B;&#x3002;</p>
<ul>
<li>soapcpp2<br>
<strong>-1 &#x6216; -2</strong> &#x8BF4;&#x660E;&#x4F7F;&#x7528;&#x7684;soap&#x7684;&#x7248;&#x672C;&#x53F7;&#x3002;<br>
<strong>-c</strong> &#x4EA7;&#x751F;&#x7EAF;C&#x4EE3;&#x7801;&#xFF0C;&#x5426;&#x5219;&#x662F;C++&#x4EE3;&#x7801;(&#x4E0E;&#x5934;&#x6587;&#x4EF6;&#x6709;&#x5173;)<br>
<strong>-C</strong> &#x4EC5;&#x751F;&#x6210;&#x5BA2;&#x6237;&#x7AEF;&#x4EE3;&#x7801;<br>
<strong>-I</strong> &#x6307;&#x5B9A;import&#x8DEF;&#x5F84;&#xFF08;&#x89C1;&#x4E0A;&#x6587;&#xFF09;<br>
-i &#x751F;&#x6210;C++&#x5305;&#x88C5;&#xFF0C;&#x5BA2;&#x6237;&#x7AEF;&#x4E3A;xxxxProxy.h(.cpp)&#xFF0C;&#x670D;&#x52A1;&#x5668;&#x7AEF;&#x4E3A;xxxxService.h(.cpp), &#x8FD9;&#x79CD;object&#x7EE7;&#x627F;&#x4E8E;soap struct&#x3002;<br>
-j -j&#x3000;&#x3000;&#x3000;&#x3000; &#x548C;-i&#x7C7B;&#x4F3C;&#xFF0C;&#x533A;&#x522B;&#x5728;&#x4E8E;&#x751F;&#x6210;&#x7684;&#x4EE3;&#x7406;&#x7C7B;&#x4E0D;&#x7EE7;&#x627F;&#x4E8E;soap struct&#xFF0C;&#x800C;&#x662F;&#x5305;&#x542B;&#x4E86;&#x5305;&#x542B;&#x4E86;&#x4E00;&#x4E2A;soap&#x7ED3;&#x6784;&#x7684;&#x6307;&#x9488;&#x3002;&#x6B64;&#x79CD;&#x65B9;&#x5F0F;&#x751F;&#x5B58;&#x7684;&#x4EE3;&#x7406;&#x7C7B;&#x4FBF;&#x4E8E;&#x4E92;&#x76F8;&#x901A;&#x4FE1;&#x3002;<br>
<strong>-L</strong> &#x4E0D;&#x8981;&#x4EA7;&#x751F;soapClientLib.c&#x548C;soapServerLib.c&#x6587;&#x4EF6;<br>
-p &#x4F7F;&#x7528;&#x540E;&#x4EA7;&#x751F;&#x7684;&#x6587;&#x4EF6;&#x524D;&#x7F00;&#x4E0D;&#x5728;&#x662F;soapC,soapClient,&#x800C;&#x662F;&#x4F60;&#x6240;&#x77E5;&#x540D;&#x7684;nameC,nameClient.<br>
<strong>-S</strong> &#x4EC5;&#x751F;&#x6210;&#x670D;&#x52A1;&#x5668;&#x7AEF;&#x4EE3;&#x7801;<br>
<strong>-x</strong> &#x4E0D;&#x8981;&#x4EA7;&#x751F;XML&#x793A;&#x4F8B;&#x6587;&#x4EF6;</li>
<li>&#x793A;&#x4F8B;<pre data-role="codeBlock" data-info="shell {.line-numbers}" class="language-shell line-numbers"><span class="token comment"># &#x5BA2;&#x6237;&#x7AEF;&#x4F7F;&#x7528;&#x547D;&#x4EE4;</span>
$ soapcpp2 -Lx -C xxx.h -I <span class="token operator">&lt;</span>path_to<span class="token operator">&gt;</span>/import
<span class="token comment"># &#x670D;&#x52A1;&#x7AEF;&#x4F7F;&#x7528;&#x547D;&#x4EE4;</span>
$ soapcpp2 -Lx -S xxx.h -I <span class="token operator">&lt;</span>path_to<span class="token operator">&gt;</span>/import
<span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span></span></pre></li>
<li>&#x5907;&#x6CE8;</li>
</ul>
<h3 class="mume-header undefined" id="H-5-4">5.4 &#x5E93;&#x79FB;&#x690D;&#x65B9;&#x6CD5;</h3>

<ul>
<li>&#x64CD;&#x4F5C;&#x6B65;&#x9AA4;&#x5982;&#x4E0B;:
<ol>
<li>wsdl2h: (.wsdl -&gt; .h)</li>
<li>soapcpp2: (.h-&gt; *.c, *.h)</li>
<li>&#x590D;&#x5236;&#x5934;&#x6587;&#x4EF6;</li>
</ol>
</li>
</ul>
<h3 class="mume-header undefined" id="H-5-5">5.5 wsdl&#x6587;&#x4EF6;&#x5143;&#x7D20;&#x8BF4;&#x660E;</h3>

<h4 class="mume-header undefined" id="H-5-5-1">5.5.1 &#x6982;&#x8FF0;</h4>

<p>&#x4E00;&#x4E2A;WSDL&#x6587;&#x6863;&#x901A;&#x5E38;&#x5305;&#x542B;7&#x4E2A;&#x91CD;&#x8981;&#x7684;&#x5143;&#x7D20;&#xFF0C;&#x5373;types&#x3001;import&#x3001;message&#x3001;portType&#x3001;operation&#x3001;binding&#x3001; service&#x5143;&#x7D20;&#x3002;&#x8FD9;&#x4E9B;&#x5143;&#x7D20;&#x5D4C;&#x5957;&#x5728;definitions&#x5143;&#x7D20;&#x4E2D;&#xFF0C;definitions&#x662F;WSDL&#x6587;&#x6863;&#x7684;&#x6839;&#x5143;&#x7D20;&#x3002;<br>
WSDL&#x7684;xml schema&#x53EF;&#x4EE5;&#x53C2;&#x7167;&#x5982;&#x4E0B;&#x7F51;&#x5740;&#xFF1A;<a href="http://schemas.xmlsoap.org/wsdl/">http://schemas.xmlsoap.org/wsdl/</a></p>
<ul>
<li>Types - &#x6570;&#x636E;&#x7C7B;&#x578B;&#x5B9A;&#x4E49;&#x7684;&#x5BB9;&#x5668;<br>
&#x5B83;&#x4F7F;&#x7528;&#x67D0;&#x79CD;&#x7C7B;&#x578B;&#x7CFB;&#x7EDF;(&#x4E00;&#x822C;&#x5730;&#x4F7F;&#x7528;XML Schema&#x4E2D;&#x7684;&#x7C7B;&#x578B;&#x7CFB;&#x7EDF;)&#x3002;</li>
<li>Message - &#x901A;&#x4FE1;&#x6D88;&#x606F;&#x7684;&#x6570;&#x636E;&#x7ED3;&#x6784;&#x7684;&#x62BD;&#x8C61;&#x7C7B;&#x578B;&#x5316;&#x5B9A;&#x4E49;&#x3002;<br>
&#x4F7F;&#x7528;Types&#x6240;&#x5B9A;&#x4E49;&#x7684;&#x7C7B;&#x578B;&#x6765;&#x5B9A;&#x4E49;&#x6574;&#x4E2A;&#x6D88;&#x606F;&#x7684;&#x6570;&#x636E;&#x7ED3;&#x6784;&#x3002;</li>
<li>Operation - &#x5BF9;&#x670D;&#x52A1;&#x4E2D;&#x6240;&#x652F;&#x6301;&#x7684;&#x64CD;&#x4F5C;&#x7684;&#x62BD;&#x8C61;&#x63CF;&#x8FF0;&#xFF0C;<br>
&#x4E00;&#x822C;&#x5355;&#x4E2A;Operation&#x63CF;&#x8FF0;&#x4E86;&#x4E00;&#x4E2A;&#x8BBF;&#x95EE;&#x5165;&#x53E3;&#x7684;&#x8BF7;&#x6C42;/&#x54CD;&#x5E94;&#x6D88;&#x606F;&#x5BF9;&#x3002;</li>
<li>PortType - &#x5BF9;&#x4E8E;&#x67D0;&#x4E2A;&#x8BBF;&#x95EE;&#x5165;&#x53E3;&#x70B9;&#x7C7B;&#x578B;&#x6240;&#x652F;&#x6301;&#x7684;&#x64CD;&#x4F5C;&#x7684;&#x62BD;&#x8C61;&#x96C6;&#x5408;&#xFF0C;<br>
&#x8FD9;&#x4E9B;&#x64CD;&#x4F5C;&#x53EF;&#x4EE5;&#x7531;&#x4E00;&#x4E2A;&#x6216;&#x591A;&#x4E2A;&#x670D;&#x52A1;&#x8BBF;&#x95EE;&#x70B9;&#x6765;&#x652F;&#x6301;&#x3002;</li>
<li>Binding - &#x7279;&#x5B9A;&#x7AEF;&#x53E3;&#x7C7B;&#x578B;&#x7684;&#x5177;&#x4F53;&#x534F;&#x8BAE;&#x548C;&#x6570;&#x636E;&#x683C;&#x5F0F;&#x89C4;&#x8303;&#x7684;&#x7ED1;&#x5B9A;&#x3002;</li>
<li>Port - &#x5B9A;&#x4E49;&#x4E3A;&#x534F;&#x8BAE;/&#x6570;&#x636E;&#x683C;&#x5F0F;&#x7ED1;&#x5B9A;&#x4E0E;&#x5177;&#x4F53;Web&#x8BBF;&#x95EE;&#x5730;&#x5740;&#x7EC4;&#x5408;&#x7684;&#x5355;&#x4E2A;&#x670D;&#x52A1;&#x8BBF;&#x95EE;&#x70B9;&#x3002;</li>
<li>Service- &#x76F8;&#x5173;&#x670D;&#x52A1;&#x8BBF;&#x95EE;&#x70B9;&#x7684;&#x96C6;&#x5408;&#x3002;</li>
</ul>
<h4 class="mume-header undefined" id="H-5-5-2">5.5.2 &#x5C0F;&#x7ED3;</h4>

<p>WSDL&#x63CF;&#x8FF0;&#x6587;&#x4EF6;&#x7406;&#x89E3;&#x5C0F;&#x7ED3;:</p>
<ol>
<li>&#x627E;&#x65B9;&#x6CD5;<br>
&#x641C;&#x7D22;<code>&lt;wsdl:message</code>,&#x4E14;&#x5176;&#x4E2D;name&#x5C5E;&#x6027;&#x7684;&#x503C;&#x6CA1;&#x6709;response&#x7ED3;&#x5C3E;&#xFF0C;<br>
&#x5982;name=&quot;getCatsByUserResponse&quot;&#x4E0D;&#x7B26;&#x5408;&#xFF1B;&#x5176;&#x4ED6;&#x7684;&#x5C31;&#x662F;&#x8FD9;&#x4E2A;&#x63A5;&#x53E3;&#x7684;&#x65B9;&#x6CD5;</li>
<li>&#x627E;&#x53C2;&#x6570;<br>
&#x641C;&#x7D22;<code>&lt;wsdl:message</code>&#x7684;&#x5B50;&#x5143;&#x7D20;<code>&lt;wsdl:part</code>&#xFF0C;<br>
<code>&lt;wsdl:part</code>&#x4E2D;&#x7684;name&#x7684;&#x5C5E;&#x6027;&#x503C;&#x5C31;&#x662F;&#x5728;wsdl:types&#x5B9A;&#x4E49;&#xFF0C;&#x53BB;wsdl:types&#x53EF;&#x4EE5;&#x627E;&#x5230;&#x53C2;&#x6570;&#x540D;&#x548C;&#x53C2;&#x6570;&#x7C7B;&#x578B;</li>
<li>&#x627E;&#x63A5;&#x53E3;&#x4FE1;&#x606F;<br>
&#x641C;&#x7D22;<code>&lt;wsdl:portType</code>&#x5176;&#x4E2D;&#x7684;name&#x5C5E;&#x6027;&#x5C31;&#x662F;&#x63A5;&#x53E3;&#x7684;&#x6700;&#x7EC8;&#x8DEF;&#x5F84;&#xFF0C;<br>
&#x5982;<code>&lt;wsdl:portType name=&#x201C;HelloWorld&#x201D;&gt;</code>&#x8FD9;&#x4E2A;MyWebService&#x548C;http://localhost:8080/helloWorld?wsdl=HelloWorld.wsdl&#x6700;&#x540E;&#x7684;HelloWorld(&#x7B2C;&#x4E8C;&#x4E2A;HelloWorld)&#x4E00;&#x81F4;</li>
<li>&#x627E;&#x4F20;&#x5165;&#x4F20;&#x51FA;&#x4FE1;&#x606F;:<br>
<code>&lt;wsdl:portType</code>&#x7684;&#x5B50;&#x5143;&#x7D20;<code>&lt;wsdl:operation</code>&#x4EE3;&#x8868;&#x8BE5;&#x63A5;&#x53E3;&#x7684;&#x65B9;&#x6CD5;&#x540D;(@WebMethod&#x4E0A;&#x6CE8;&#x89E3;&#x7684;)&#x3002;<br>
<code>&lt;wsdl:operation</code>&#x7684;&#x5B50;&#x5143;&#x7D20;<code>&lt;wsdl:input</code>&#x662F;&#x8868;&#x793A;&#x8F93;&#x5165;&#x4FE1;&#x606F;&#xFF0C;<br>
&#x5982;<code>&lt;wsdl:input message=&#x201C;ns1:sayHi&#x201D; name=&#x201C;sayHi&#x201D;&gt;</code>&#xFF0C;&#x8FD9;&#x4E2A;message&#x7684;&#x5C5E;&#x6027;&#x503C;sayHi&#x53C8;&#x4E0E;<code>&lt;wsdl:message</code>&#x7684;&#x8FD9;&#x4E2A;&#x5BF9;&#x5E94;&#x8D77;&#x6765;&#x3002;<br>
&#x76F8;&#x540C;&#x7684;&#xFF0C;&#x8F93;&#x51FA;&#x4FE1;&#x606F;<code>&lt;wsdl:output message</code>&#x548C;&#x8F93;&#x5165;&#x4FE1;&#x606F;&#x662F;&#x4E00;&#x6837;&#x7684;&#x5206;&#x6790;&#x539F;&#x7406;&#x3002;</li>
</ol>
<h3 class="mume-header undefined" id="H-5-6">5.6 SOAP 1.1 vs SOAP 1.2</h3>

<ul>
<li>&#x533A;&#x522B;&#x5982;&#x4E0B;
<ol>
<li>contentType&#x4E0D;&#x540C;
<ul>
<li>&#x666E;&#x901A;http post&#x7684;contentType&#x4E3A;: application/x-www-form-urlencoded<br>
WebService&#x7684;contentType&#x4E3A;: &#x5373;&#x5728;Http&#x7684;&#x57FA;&#x7840;&#x4E0A;&#x53D1;SOAP&#x534F;&#x8BAE;</li>
<li>text/xml &#x8FD9;&#x662F;&#x57FA;&#x4E8E;soap1.1&#x534F;&#x8BAE;&#x3002;</li>
<li>application/soap+xml &#x8FD9;&#x662F;&#x57FA;&#x4E8E;soap1.2&#x534F;&#x8BAE;&#x3002;</li>
</ul>
</li>
<li>&#x547D;&#x540D;&#x7A7A;&#x95F4;&#x4E0D;&#x540C;
<ul>
<li>SOAP1.1<br>
xmlns:soap=&#x201C;<a href="http://schemas.xmlsoap.org/soap/envelope/%E2%80%9C">http://schemas.xmlsoap.org/soap/envelope/&#x201C;</a></li>
<li>SOAP1.2<br>
xmlns:soap=&quot;<a href="http://www.w3.org/2003/05/soap-envelope%E2%80%9C">http://www.w3.org/2003/05/soap-envelope&#x201C;</a></li>
</ul>
</li>
<li>&#x5934;&#x4FE1;&#x606F;&#x4E0A;&#x4E0D;&#x540C;<br>
&#x524D;&#x8005;&#x5B58;&#x5728;SOAPAction&#x7684;&#x8BF7;&#x6C42;&#x5934;&#xFF1B;&#x540E;&#x8005;&#x4E0D;&#x5B58;&#x5728;&#x3002;</li>
<li>WSDL&#x6587;&#x4EF6;&#x4E0D;&#x540C;<br>
Soap1.1&#x662F;&#x4EE5;&#xFF1A;soap:address&#x5B9A;&#x4E49;<br>
Soap1.2&#x662F;&#x4EE5;: soap12:address&#x5B9A;&#x4E49;&#x3002;<a href="..\..\jdk1.xn--612-728dq19ehoah3ssxedo3c4m7bmoxa">//jdk1.6&#x4E0D;&#x652F;&#x6301;12&#x5F62;&#x5F0F;&#x7684;&#x8BBF;&#x95EE;</a></li>
<li>Request&#x793A;&#x4F8B;
<ul>
<li>SOAP1.1<pre data-role="codeBlock" data-info="html {.line-numbers}" class="language-html line-numbers">POST /WSShakespeare.asmx HTTP/1.1
Host: www.xmlme.com 
Content-Type: text/xml; charset=utf-8
Content-Length: length 
SOAPAction: &quot;http://xmlme.com/WebServices/GetSpeech&quot;

<span class="token prolog">&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;</span> 
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token namespace">soap:</span>Envelope</span> <span class="token attr-name"><span class="token namespace">xmlns:</span>xsi</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>http://www.w3.org/2001/XMLSchema-instance<span class="token punctuation">&quot;</span></span>
  <span class="token attr-name"><span class="token namespace">xmlns:</span>xsd</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>http://www.w3.org/2001/XMLSchema<span class="token punctuation">&quot;</span></span>
  <span class="token attr-name"><span class="token namespace">xmlns:</span>soap</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>http://schemas.xmlsoap.org/soap/envelope/<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span> 
  <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token namespace">soap:</span>Body</span><span class="token punctuation">&gt;</span></span> 
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>GetSpeech</span> <span class="token attr-name">xmlns</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>http://xmlme.com/WebServices<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span> 
      <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>Request</span><span class="token punctuation">&gt;</span></span>string<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>Request</span><span class="token punctuation">&gt;</span></span> 
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>GetSpeech</span><span class="token punctuation">&gt;</span></span> 
  <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token namespace">soap:</span>Body</span><span class="token punctuation">&gt;</span></span> 
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token namespace">soap:</span>Envelope</span><span class="token punctuation">&gt;</span></span>        
<span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></pre></li>
<li>SOAP1.2<pre data-role="codeBlock" data-info="html {.line-numbers}" class="language-html line-numbers">POST /WSShakespeare.asmx HTTP/1.1
Host: www.xmlme.com 
Content-Type: application/soap+xml; charset=utf-8
Content-Length: length 

<span class="token prolog">&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;</span> 
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token namespace">soap12:</span>Envelope</span> <span class="token attr-name"><span class="token namespace">xmlns:</span>xsi</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>http://www.w3.org/2001/XMLSchema-instance<span class="token punctuation">&quot;</span></span>
  <span class="token attr-name"><span class="token namespace">xmlns:</span>xsd</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>http://www.w3.org/2001/XMLSchema<span class="token punctuation">&quot;</span></span>
  <span class="token attr-name"><span class="token namespace">xmlns:</span>soap12</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>http://www.w3.org/2003/05/soap-envelope<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span> 
  <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token namespace">soap12:</span>Body</span><span class="token punctuation">&gt;</span></span> 
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>GetSpeech</span> <span class="token attr-name">xmlns</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>http://xmlme.com/WebServices<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span> 
      <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>Request</span><span class="token punctuation">&gt;</span></span>string<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>Request</span><span class="token punctuation">&gt;</span></span> 
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>GetSpeech</span><span class="token punctuation">&gt;</span></span> 
  <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token namespace">soap12:</span>Body</span><span class="token punctuation">&gt;</span></span> 
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token namespace">soap12:</span>Envelope</span><span class="token punctuation">&gt;</span></span>        
<span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></pre></li>
</ul>
</li>
</ol>
</li>
</ul>
<h3 class="mume-header undefined" id="H-5-7">5.7 GSOAP&#x7528;&#x4F8B;&#xFF1A;C++&#x7248;&#x672C;</h3>

<p>&#x5728;&#x4E0A;&#x9762;&#x7AE0;&#x8282;&#x7684;&#x57FA;&#x7840;&#x4E0A;&#xFF0C;&#x8FDB;&#x884C;C++&#x7248;&#x672C;&#x7684;&#x6D4B;&#x8BD5;&#x3002;</p>
<h4 class="mume-header undefined" id="H-5-7-1">5.7.1 &#x7F16;&#x8F91;&#x63A5;&#x53E3;&#x6587;&#x4EF6;(<code>zzz.h</code>)</h4>

<pre data-role="codeBlock" data-info="shell {.line-numbers}" class="language-shell line-numbers">$ <span class="token function">cat</span> zzz.h
//gsoap ns <span class="token function">service</span> name: zzz
//gsoap ns <span class="token function">service</span> style: rpc
//gsoap ns <span class="token function">service</span> namespace: http://10.10.90.46:9000/zzz.wsdl
//gsoap ns <span class="token function">service</span> location: http://10.10.90.46:9000
//gsoap ns <span class="token function">service</span> encoding: encoded
//gsoap ns schema namespace: urn:zzz

int ns__add<span class="token punctuation">(</span>int num1, int num2, int *sum<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></pre><h4 class="mume-header undefined" id="H-5-7-2">5.7.2 &#x7F16;&#x8F91;&#x670D;&#x52A1;&#x7AEF;&#x6587;&#x4EF6;(<code>zzzserver.cpp</code>)</h4>

<pre data-role="codeBlock" data-info="c {.line-numbers}" class="language-c line-numbers">$ cat zzzserver<span class="token punctuation">.</span>cpp
<span class="token macro property"><span class="token directive-hash">#</span><span class="token directive keyword">include</span> <span class="token string">&quot;soapzzzService.h&quot;</span></span>
<span class="token macro property"><span class="token directive-hash">#</span><span class="token directive keyword">include</span> <span class="token string">&quot;zzz.nsmap&quot;</span></span>

<span class="token keyword keyword-int">int</span> <span class="token function">main</span><span class="token punctuation">(</span><span class="token keyword keyword-int">int</span> argc<span class="token punctuation">,</span> <span class="token keyword keyword-char">char</span> <span class="token operator">*</span><span class="token operator">*</span>argv<span class="token punctuation">)</span>
<span class="token punctuation">{</span> 
    zzzService sms<span class="token punctuation">;</span>

    <span class="token keyword keyword-if">if</span> <span class="token punctuation">(</span>argc <span class="token operator">&lt;</span> <span class="token number">2</span><span class="token punctuation">)</span>
        sms<span class="token punctuation">.</span><span class="token function">serve</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>       <span class="token comment">/* serve as CGI application */</span>
    <span class="token keyword keyword-else">else</span>
    <span class="token punctuation">{</span> 
        <span class="token keyword keyword-int">int</span> port <span class="token operator">=</span> <span class="token function">atoi</span><span class="token punctuation">(</span>argv<span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

        <span class="token keyword keyword-if">if</span> <span class="token punctuation">(</span><span class="token operator">!</span>port<span class="token punctuation">)</span>
        <span class="token punctuation">{</span> 
            <span class="token function">fprintf</span><span class="token punctuation">(</span><span class="token constant">stderr</span><span class="token punctuation">,</span> <span class="token string">&quot;Usage: SmsWBSserver++ &lt;port&gt;\n&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token function">exit</span><span class="token punctuation">(</span><span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span>

        <span class="token comment">/* run iterative server on port until fatal error */</span>
        <span class="token keyword keyword-if">if</span> <span class="token punctuation">(</span>sms<span class="token punctuation">.</span><span class="token function">run</span><span class="token punctuation">(</span>port<span class="token punctuation">)</span><span class="token punctuation">)</span>
        <span class="token punctuation">{</span> 
            sms<span class="token punctuation">.</span><span class="token function">soap_stream_fault</span><span class="token punctuation">(</span>std<span class="token operator">::</span>cerr<span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token function">exit</span><span class="token punctuation">(</span><span class="token operator">-</span><span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span>
    <span class="token punctuation">}</span>

    <span class="token keyword keyword-return">return</span> <span class="token number">0</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>

<span class="token keyword keyword-int">int</span> zzzService<span class="token operator">::</span><span class="token function">add</span><span class="token punctuation">(</span><span class="token keyword keyword-int">int</span> num1<span class="token punctuation">,</span> <span class="token keyword keyword-int">int</span> num2<span class="token punctuation">,</span> <span class="token keyword keyword-int">int</span> <span class="token operator">*</span>sum<span class="token punctuation">)</span>
<span class="token punctuation">{</span>
    <span class="token operator">*</span>sum <span class="token operator">=</span> num1 <span class="token operator">+</span> num2<span class="token punctuation">;</span>
    <span class="token keyword keyword-return">return</span> SOAP_OK<span class="token punctuation">;</span>
<span class="token punctuation">}</span>
<span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></pre><h4 class="mume-header undefined" id="H-5-7-3">5.7.3 &#x7F16;&#x8F91;&#x5BA2;&#x6237;&#x7AEF;&#x6587;&#x4EF6;(<code>zzztest.cpp</code>)</h4>

<pre data-role="codeBlock" data-info="shell {.line-numbers}" class="language-shell line-numbers">$ <span class="token function">cat</span> zzztst.cpp
<span class="token comment">#include &lt;stdio.h&gt;</span>
<span class="token comment">#include &lt;stdlib.h&gt;</span>
<span class="token comment">#include &quot;soapzzzProxy.h&quot;</span>
<span class="token comment">#include &quot;zzz.nsmap&quot;</span>

int main<span class="token punctuation">(</span>int argc, char **argv<span class="token punctuation">)</span>
<span class="token punctuation">{</span>
    int result <span class="token operator">=</span> -1<span class="token punctuation">;</span>
    const char* <span class="token assign-left variable">server</span><span class="token operator">=</span><span class="token string">&quot;http://localhost:9000&quot;</span><span class="token punctuation">;</span>

    int num1 <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span>
    int num2 <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span>
    int <span class="token function">sum</span> <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span>

    if<span class="token punctuation">(</span> argc <span class="token operator">&lt;</span> <span class="token number">3</span> <span class="token punctuation">)</span>
    <span class="token punctuation">{</span>
        printf<span class="token punctuation">(</span><span class="token string">&quot;usage: %s num1 num2 <span class="token entity" title="\n">\n</span>&quot;</span>, argv<span class="token punctuation">[</span><span class="token number">0</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        exit<span class="token punctuation">(</span><span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>

    num1 <span class="token operator">=</span> atoi<span class="token punctuation">(</span>argv<span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    num2 <span class="token operator">=</span> atoi<span class="token punctuation">(</span>argv<span class="token punctuation">[</span><span class="token number">2</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

    zzzProxy  sms<span class="token punctuation">;</span>
    result <span class="token operator">=</span> sms.add<span class="token punctuation">(</span>num1, num2, <span class="token operator">&amp;</span><span class="token function">sum</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token keyword keyword-if">if</span> <span class="token punctuation">(</span>result <span class="token operator">!=</span> <span class="token number">0</span><span class="token punctuation">)</span>
    <span class="token punctuation">{</span>
        printf<span class="token punctuation">(</span><span class="token string">&quot;soap err, errcode = %d <span class="token entity" title="\n">\n</span>&quot;</span>, result<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
    <span class="token keyword keyword-else">else</span>
    <span class="token punctuation">{</span>
        printf<span class="token punctuation">(</span><span class="token string">&quot;%d + %d = %d <span class="token entity" title="\n">\n</span>&quot;</span>, num1, num2, <span class="token function">sum</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>

    <span class="token builtin class-name">return</span> <span class="token number">0</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
<span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></pre><h4 class="mume-header undefined" id="H-5-7-4">5.7.4 &#x7F16;&#x8F91;Makefile</h4>

<pre data-role="codeBlock" data-info="makefile {.line-numbers}" class="language-makefile line-numbers">$ cat Makefile
GSOAP_ROOT<span class="token operator">=</span>/usr/local/gSOAP
WSNAME0<span class="token operator">=</span>soap
WSNAME<span class="token operator">=</span>zzz
CC<span class="token operator">=</span>g++ -g -DWITH_NONAMESPACES
INCLUDE<span class="token operator">=</span>-I <span class="token variable">$</span><span class="token punctuation">(</span>GSOAP_ROOT<span class="token punctuation">)</span>/<span class="token keyword keyword-include">include</span>
SERVER_OBJS<span class="token operator">=</span><span class="token variable">$</span><span class="token punctuation">(</span>WSNAME0<span class="token punctuation">)</span>C.o <span class="token variable">$</span><span class="token punctuation">(</span>WSNAME0<span class="token punctuation">)</span><span class="token variable">$</span><span class="token punctuation">(</span>WSNAME<span class="token punctuation">)</span>Service.o stdsoap2.o
CLIENT_OBJS<span class="token operator">=</span><span class="token variable">$</span><span class="token punctuation">(</span>WSNAME0<span class="token punctuation">)</span><span class="token variable">$</span><span class="token punctuation">(</span>WSNAME<span class="token punctuation">)</span>Proxy.o <span class="token variable">$</span><span class="token punctuation">(</span>WSNAME0<span class="token punctuation">)</span>C.o stdsoap2.o
ALL_OBJS<span class="token operator">=</span><span class="token variable">$</span><span class="token punctuation">{</span>WSNAME<span class="token punctuation">}</span>server.o <span class="token variable">$</span><span class="token punctuation">(</span>WSNAME0<span class="token punctuation">)</span>C.o <span class="token variable">$</span><span class="token punctuation">(</span>WSNAME0<span class="token punctuation">)</span><span class="token variable">$</span><span class="token punctuation">(</span>WSNAME<span class="token punctuation">)</span>Service.o <span class="token variable">$</span><span class="token punctuation">(</span>WSNAME0<span class="token punctuation">)</span><span class="token variable">$</span><span class="token punctuation">(</span>WSNAME<span class="token punctuation">)</span>Proxy.o <span class="token variable">$</span><span class="token punctuation">{</span>WSNAME<span class="token punctuation">}</span>test.o
<span class="token comment">#GSOAP_SRC=/usr/local/gsoap-2.7/gsoap</span>

<span class="token symbol">all</span><span class="token punctuation">:</span>server

<span class="token symbol"><span class="token variable">$</span>{WSNAME}.wsdl</span><span class="token punctuation">:</span><span class="token variable">$</span><span class="token punctuation">{</span>WSNAME<span class="token punctuation">}</span>.h
        <span class="token variable">$</span><span class="token punctuation">(</span>GSOAP_ROOT<span class="token punctuation">)</span>/bin/soapcpp2 -i <span class="token variable">$</span><span class="token punctuation">(</span>GSOAP_ROOT<span class="token punctuation">)</span>/import <span class="token variable">$</span><span class="token punctuation">{</span>WSNAME<span class="token punctuation">}</span>.h

<span class="token symbol">stdsoap2.o</span><span class="token punctuation">:</span><span class="token variable">$</span><span class="token punctuation">(</span>GSOAP_ROOT<span class="token punctuation">)</span>/src/stdsoap2.cpp
        <span class="token variable">$</span><span class="token punctuation">(</span>CC<span class="token punctuation">)</span> -c <span class="token variable">$?</span> <span class="token variable">$</span><span class="token punctuation">(</span>INCLUDE<span class="token punctuation">)</span>

<span class="token symbol"><span class="token variable">$</span>(ALL_OBJS)</span><span class="token punctuation">:</span>%.o<span class="token punctuation">:</span>%.cpp
        <span class="token variable">$</span><span class="token punctuation">(</span>CC<span class="token punctuation">)</span> -c <span class="token variable">$?</span> <span class="token variable">$</span><span class="token punctuation">(</span>INCLUDE<span class="token punctuation">)</span>

<span class="token symbol">server</span><span class="token punctuation">:</span>Makefile <span class="token variable">$</span><span class="token punctuation">{</span>WSNAME<span class="token punctuation">}</span>.wsdl <span class="token variable">$</span><span class="token punctuation">{</span>WSNAME<span class="token punctuation">}</span>server.o <span class="token variable">$</span><span class="token punctuation">(</span>SERVER_OBJS<span class="token punctuation">)</span>
        <span class="token variable">$</span><span class="token punctuation">(</span>CC<span class="token punctuation">)</span> <span class="token variable">$</span><span class="token punctuation">{</span>WSNAME<span class="token punctuation">}</span>server.o <span class="token variable">$</span><span class="token punctuation">(</span>SERVER_OBJS<span class="token punctuation">)</span> -o <span class="token variable">$</span><span class="token punctuation">{</span>WSNAME<span class="token punctuation">}</span>server

<span class="token symbol">client</span><span class="token punctuation">:</span>Makefile <span class="token variable">$</span><span class="token punctuation">{</span>WSNAME<span class="token punctuation">}</span>.wsdl <span class="token variable">$</span><span class="token punctuation">{</span>WSNAME<span class="token punctuation">}</span>test.cpp <span class="token variable">$</span><span class="token punctuation">(</span>ALL_OBJS<span class="token punctuation">)</span> stdsoap2.o
        <span class="token variable">$</span><span class="token punctuation">(</span>CC<span class="token punctuation">)</span> <span class="token variable">$</span><span class="token punctuation">{</span>WSNAME<span class="token punctuation">}</span>test.o <span class="token variable">$</span><span class="token punctuation">(</span>CLIENT_OBJS<span class="token punctuation">)</span> -o <span class="token variable">$</span><span class="token punctuation">{</span>WSNAME<span class="token punctuation">}</span>test

<span class="token symbol">clean</span><span class="token punctuation">:</span>
        rm -f *.o *.xml *.a *.wsdl *.nsmap <span class="token variable">$</span><span class="token punctuation">(</span>WSNAME0<span class="token punctuation">)</span>H.h <span class="token variable">$</span><span class="token punctuation">(</span>WSNAME0<span class="token punctuation">)</span>C.cpp <span class="token variable">$</span><span class="token punctuation">(</span>WSNAME0<span class="token punctuation">)</span>Server.cpp  \
        <span class="token variable">$</span><span class="token punctuation">(</span>WSNAME0<span class="token punctuation">)</span>Stub.* <span class="token variable">$</span><span class="token punctuation">(</span>WSNAME0<span class="token punctuation">)</span><span class="token variable">$</span><span class="token punctuation">(</span>WSNAME<span class="token punctuation">)</span>Service.* <span class="token variable">$</span><span class="token punctuation">(</span>WSNAME0<span class="token punctuation">)</span><span class="token variable">$</span><span class="token punctuation">(</span>WSNAME<span class="token punctuation">)</span>Proxy.* <span class="token variable">$</span><span class="token punctuation">(</span>WSNAME0<span class="token punctuation">)</span><span class="token variable">$</span><span class="token punctuation">(</span>WSNAME<span class="token punctuation">)</span>Object.* \
        <span class="token variable">$</span><span class="token punctuation">(</span>WSNAME0<span class="token punctuation">)</span>ServerLib.cpp <span class="token variable">$</span><span class="token punctuation">(</span>WSNAME0<span class="token punctuation">)</span>ClientLib.cpp <span class="token variable">$</span><span class="token punctuation">(</span>WSNAME<span class="token punctuation">)</span>server ns.xsd <span class="token variable">$</span><span class="token punctuation">(</span>WSNAME<span class="token punctuation">)</span>test
<span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></pre><h4 class="mume-header undefined" id="H-5-7-5">5.7.5 &#x7F16;&#x8BD1;&#x53CA;&#x8FD0;&#x884C;</h4>

<ul>
<li>&#x7F16;&#x8BD1;<br>
&#x4E0E;<code>C&#x7248;&#x672C;</code>&#x7F16;&#x8BD1;&#x65B9;&#x6CD5;&#x76F8;&#x540C;&#x3002;</li>
<li>&#x8FD0;&#x884C;<br>
&#x4E0E;<code>C&#x7248;&#x672C;</code>&#x8FD0;&#x884C;&#x65B9;&#x5F0F;&#x76F8;&#x540C;&#xFF0C;&#x4F46;&#x5728;&#x670D;&#x52A1;&#x7AEF;&#x770B;&#x4E0D;&#x5230;&#x65E5;&#x5FD7;&#x3002;</li>
</ul>
<h4 class="mume-header undefined" id="H-5-7-6">5.7.6 &#x4E0E;&#x5176;&#x5B83;&#x5E73;&#x53F0;&#x5BF9;&#x63A5;</h4>

<p>&#x5176;&#x5B83;&#x5E73;&#x53F0;&#x8C03;&#x7528;Web Service&#x670D;&#x52A1;&#x6240;&#x9700;&#x8981;&#x505A;&#x7684;&#x5DE5;&#x4F5C;<br>
&#x4EE5;&#x4E0A;&#x7684;C&#x548C;C++&#x7248;&#x672C;&#x7684;Web Service&#x670D;&#x52A1;&#x7AEF;&#x8FD0;&#x884C;&#x540E;&#xFF0C;&#x5728;&#x672C;&#x5730;&#x4F7F;&#x7528;curl&#x547D;&#x4EE4;<br>
<mark>&#x4EE5;&#x4E0B;&#x7528;&#x4F8B;&#xFF0C;&#x6D4B;&#x8BD5;&#x672A;&#x901A;&#x8FC7;&#xFF0C;&#x539F;&#x56E0;&#x5F85;&#x67E5;</mark></p>
<ul>
<li>&#x5BA2;&#x6237;&#x7AEF;&#x8BF7;&#x6C42;&#x7F51;&#x9875;<pre data-role="codeBlock" data-info="shell {.line-numbers}" class="language-shell line-numbers">$ <span class="token function">curl</span> http://10.10.90.46:9000/yyy?wsdl
<span aria-hidden="true" class="line-numbers-rows"><span></span></span></pre><ul>
<li>&#x5BA2;&#x6237;&#x7AEF;:<pre data-role="codeBlock" data-info="xml {.line-numbers}" class="language-xml line-numbers"><span class="token prolog">&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;</span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token namespace">SOAP-ENV:</span>Envelope</span> <span class="token attr-name"><span class="token namespace">xmlns:</span>SOAP-ENV</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>http://schemas.xmlsoap.org/soap/envelope/<span class="token punctuation">&quot;</span></span> <span class="token attr-name"><span class="token namespace">xmlns:</span>SOAP-ENC</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>http://schemas.xmlsoap.org/soap/encoding/<span class="token punctuation">&quot;</span></span> <span class="token attr-name"><span class="token namespace">xmlns:</span>xsi</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>http://www.w3.org/2001/XMLSchema-instance<span class="token punctuation">&quot;</span></span> <span class="token attr-name"><span class="token namespace">xmlns:</span>xsd</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>http://www.w3.org/2001/XMLSchema<span class="token punctuation">&quot;</span></span> <span class="token attr-name"><span class="token namespace">xmlns:</span>ns</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>urn:zzz<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token namespace">SOAP-ENV:</span>Body</span><span class="token punctuation">&gt;</span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token namespace">SOAP-ENV:</span>Fault</span><span class="token punctuation">&gt;</span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>faultcode</span><span class="token punctuation">&gt;</span></span>SOAP-ENV:Client<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>faultcode</span><span class="token punctuation">&gt;</span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>faultstring</span><span class="token punctuation">&gt;</span></span>HTTP GET method not implemented<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>faultstring</span><span class="token punctuation">&gt;</span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token namespace">SOAP-ENV:</span>Fault</span><span class="token punctuation">&gt;</span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token namespace">SOAP-ENV:</span>Body</span><span class="token punctuation">&gt;</span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span><span class="token namespace">SOAP-ENV:</span>Envelope</span><span class="token punctuation">&gt;</span></span>
<span aria-hidden="true" class="line-numbers-rows"><span></span><span></span></span></pre></li>
<li>&#x670D;&#x52A1;&#x7AEF;<pre data-role="codeBlock" data-info="shell {.line-numbers}" class="language-shell line-numbers"><span class="token punctuation">[</span>root@P46 cplusplus<span class="token punctuation">]</span><span class="token comment"># ./zzzserver 9000        </span>
SOAP <span class="token number">1.1</span> fault SOAP-ENV:Client<span class="token punctuation">[</span>no subcode<span class="token punctuation">]</span>
<span class="token string">&quot;HTTP GET method not implemented&quot;</span>
Detail: <span class="token punctuation">[</span>no detail<span class="token punctuation">]</span>    
<span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span></span></pre></li>
<li>&#x8BF4;&#x660E;<br>
&#x5BA2;&#x6237;&#x7AEF;&#x4F1A;&#x8FD4;&#x56DE;XML&#x6587;&#x4EF6;&#x5185;&#x5BB9;&#xFF0C;&#x4F46;&#x662F;&#x5E76;&#x65E0;Web Service&#x7684;&#x529F;&#x80FD;&#x51FD;&#x6570;&#x63CF;&#x8FF0;&#xFF0C;&#x539F;&#x56E0;&#x662F;&#x5C1A;&#x672A;&#x5B9E;&#x73B0;&#x5141;&#x8BB8;&#x5BA2;&#x6237;&#x7AEF;&#x901A;&#x8FC7;http&#x7684;get&#x64CD;&#x4F5C;&#x6765;&#x83B7;&#x53D6; SmsWBS.wsdl&#x6587;&#x4EF6;&#x3002;&#x56E0;&#x6B64;&#xFF0C;&#x9700;&#x8981;&#x8865;&#x5145;&#x5B9E;&#x73B0;&#x8FD9;&#x4E00;&#x90E8;&#x5206;&#xFF0C;&#x4EE5;C++&#x7248;&#x672C;&#x4E3A;&#x4F8B;&#xFF0C;&#x5B8C;&#x5584;&#x540E;&#x7684;&#x4EE3;&#x7801;&#x5982;&#x4E0B;:</li>
</ul>
</li>
</ul>

      </div>
      
      
    
    
    
    
    
    
    
    
  
    </body></html>